Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastLED.h"
- #define NUM_LEDS 10
- #define DATA_PIN 12
- #define BUTTON_PIN 3
- #define POT_PIN A0
- CRGB leds[NUM_LEDS];
- int stripState = 0;
- int caseMax = 2;
- int buttonState = LOW;
- int lastButtonState = LOW;
- long lastDebounceTime = 0;
- int debounceDelay = 50;
- long modeTime;
- int modeDelay = 10000;
- int buttonReading;
- void setup() {
- FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
- pinMode(BUTTON_PIN, INPUT_PULLUP);
- Serial.begin(9600);
- }
- void loop() {
- buttonReading = digitalRead(BUTTON_PIN);
- Serial.println(digitalRead(BUTTON_PIN));
- /*
- if (buttonReading != lastButtonState) {
- lastDebounceTime = millis();
- }
- if ((millis() - lastDebounceTime) > debounceDelay) {
- if (buttonReading != buttonState) {
- buttonState = buttonReading;
- if (buttonState == LOW) {
- stripState = (stripState + 1) % caseMax;
- modeTime = millis();
- }
- }
- }
- lastButtonState = buttonReading;
- */
- if (millis() > modeTime + modeDelay) {
- modeTime = millis();
- stripState = (stripState + 1) % caseMax;
- }
- if (stripState == 0) {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = CRGB::White;
- }
- }
- if (stripState == 1) {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = CHSV(analogRead(POT_PIN), 255, 255);
- }
- }
- FastLED.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment