#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;
    }
}