#include <FastLED.h>
#include <ezButton.h>
#define NUM_LEDS 46
#define LED_PIN 8
ezButton button(5); // create ezButton object that attach to pin
bool state = 0;
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(9600); // serial monitor
button.setDebounceTime(50); // set debounce time to 100 milliseconds
pinMode(13, OUTPUT);
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS); //specify led model and DIN pin
FastLED.clear(); // clear all pixel data
FastLED.show(); //shows pixel data
FastLED.setBrightness(255); // brightness 0 - 255
}
void loop() {
button.loop(); // MUST call the loop() function first
if(button.isPressed())
if(state == 0) {
Serial.println("Turn ON");
digitalWrite(13, HIGH);
for (int i = 0; i <= 45; i++) {
leds[i] = CRGB ( 255, 255, 255); // white
FastLED.show();
button.loop();
delay(5);
}
state = 1;
}
else if(state == 1) {
Serial.println("Turn OFF");
digitalWrite(13, LOW);
for (int i = 0; i <= 45; i++) {
leds[i] = CRGB ( 0, 0, 0); // black
FastLED.show();
button.loop();
delay(5);
}
state = 0;
}
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
neopixels:DOUT
neopixels:VDD
neopixels:VSS
neopixels:DIN
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r