#include <FastLED_NeoPixel.h>
#define NUM_LEDS 9 // Number of LEDs
#define DATA_PIN 2
#define NUM_BUTTONS 9 // Number of buttons
// LED brightness, 0 (min) to 255 (max)
#define BRIGHTNESS 200
// define some basic colors to be used:
#define RED_COLOR 255, 0, 0
#define GREEN_COLOR 0, 255, 0
#define BLUE_COLOR 0, 0, 255
#define BLINK_TIME 1000 // delay time
FastLED_NeoPixel<NUM_LEDS, DATA_PIN, NEO_GRB> strip; // create a "strip" object
int button_list[NUM_BUTTONS] = {11, 12, 13, 14, 15, 16, 17, 18, 19}; // list of the buttons
int button_index = 0; // this is the order number of the button, start from 0.
// Example: button_index = 0 means the first button in the list (pin 11)
// button_index = 7 means the 8th button in the list (pin 18)
int led_index = 0; // this is the order number of the LED, start from 0. Similar to button_index
void setup() {
strip.begin(); // initialize strip (required!)
strip.setBrightness(BRIGHTNESS); //
for (button_index = 0; button_index < NUM_BUTTONS; button_index++)
{
pinMode(button_list[button_index], INPUT_PULLUP); // set the button at 'button_index' in 'button_list' to be INPUT_PULLUP
}
Serial1.begin(112500);
}
bool data;
void loop() {
for(button_index = 0; button_index < NUM_LEDS; button_index++){
data = digitalRead(button_list[button_index]);
if (data == LOW){
strip.setPixelColor(button_index, strip.Color(GREEN_COLOR)); // set pixel (single LED) at button_index to GREEN
strip.show(); // show the color
delay(BLINK_TIME);
strip.setPixelColor(button_index, strip.Color(0, 0, 0)); // set pixel to BLANK (no color)
strip.show(); // show the color
delay(BLINK_TIME);
}
}
delay(1);
}