#include <FastLED.h>
#define NUM_LEDS 20
#define DATA_PIN 2
#define COLOUR_ORDER GRB
#define CHIPSET WS2812
#define BRIGHTNESS 50
#define VOLTS 5
#define MAX_AMPS 500
CRGB leds[NUM_LEDS];
const int buttonPin = 5; // Button pin
void setup() {
//FastLED.addLeds<NEOPIXELS, DATA_PIN, COLOUR_ORDER>(leds, NUM_LEDS);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
//FastLED.setMaxPowerInVoltsAndMilliamps(VOLTS, MAX_AMPS);
//FastLED.setBrightness(BRIGHTNESS);
FastLED.clear(true);
FastLED.show();
Serial.begin(115200);
Serial.println("init");
}
int lastButtonState = 0;
long lastChanged = 0;
int buttonState = 0;
void loop() {
int count = 50;
again:
int newstate = digitalRead(buttonPin); // Reads the state of the button
if (newstate != buttonState && count-- > 0) goto again;
buttonState = newstate;
for (int i = 0; i < NUM_LEDS; i++) {
if (buttonState == HIGH) {
leds[i] = CRGB::Red;
} else {
leds[i] = CRGB::Green;
}
}
FastLED.show();
}