#include <FastLED.h>
#define LED_PIN 5
#define buttonPin1 2
#define buttonPin2 3
#define generaldelay 50
#define NUM_LEDS 50
#define BRIGHTNESS 65
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
//const unsigned int buttonPin1 = 2;
//const unsigned int buttonPin2 = 3;
bool buttonState1 = HIGH;
bool oldButtonState1 = HIGH;
bool buttonState2 = HIGH;
bool oldButtonState2 = HIGH;
bool ledState = LOW;
void setup() {
FastLED.addLeds<LED_TYPE, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(50);
pinMode(LED_PIN, OUTPUT);
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
}
void loop() {
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
if (buttonState1 != oldButtonState1 && buttonState1 == LOW)
{
ledState = !ledState;
if(ledState == HIGH)
{
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::CRGB::Yellow;
FastLED.show();
delay(generaldelay);
}
}
else
{
for(int i = NUM_LEDS - 1; i >= 0; i--) {
leds[i] = CRGB::CRGB::Black;
FastLED.show();
delay(generaldelay);
}
}
}
if (buttonState2 != oldButtonState2 && buttonState2 == LOW)
{
ledState = !ledState;
if(ledState == HIGH)
{
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::CRGB::Yellow;
FastLED.show();
delay(generaldelay);
}
}
else
{
for(int i = NUM_LEDS - 1; i >= 0; i--) {
leds[i] = CRGB::CRGB::Black;
FastLED.show();
delay(generaldelay);
}
}
}
oldButtonState1 = buttonState1;
oldButtonState2 = buttonState2;
}