#include <FastLED.h>
#define BUTTON_PIN0 4
#define BUTTON_PIN1 2
#define POTI_PIN_0 34
#define POTI_PIN_1 35
#define POTI_PIN_2 32
#define NUM_LEDS 16 // Number of LEDs
#define DATA_PIN_0 25 // Data pin of LED 1st Strip
#define DATA_PIN_1 26 // Data pin of LED 2nd Strip
int option = 0;
CRGB leds0[NUM_LEDS]; // Define an array to store LED colors
CRGB leds1[NUM_LEDS]; // Define an array to store LED colors
void IRAM_ATTR button0() {
// Serial.println("OPTION=0");
option = 0;
}
void IRAM_ATTR button1() {
// Serial.println("OPTION=1");
option = 1;
}
void setup() {
// Initialize Serial Monitor
Serial.begin(115200);
FastLED.addLeds<WS2812B, DATA_PIN_0, GRB>(leds0, NUM_LEDS); // Initialize FastLED library
FastLED.addLeds<WS2812B, DATA_PIN_1, GRB>(leds1, NUM_LEDS); // Initialize FastLED library
FastLED.setBrightness(100); // Set LED brightness (0-255)
pinMode(BUTTON_PIN0, INPUT_PULLUP);
pinMode(BUTTON_PIN1, INPUT_PULLUP);
attachInterrupt(BUTTON_PIN0, button0, FALLING);
attachInterrupt(BUTTON_PIN1, button1, FALLING);
pinMode(POTI_PIN_0, INPUT);
pinMode(POTI_PIN_1, INPUT);
pinMode(POTI_PIN_2, INPUT);
}
void loop() {
if (option == 0) {
FastLED.setBrightness(255);
while (option == 0) {
int red = map(analogRead(POTI_PIN_0), 0, 4095, 0, 255);
int green = map(analogRead(POTI_PIN_1), 0, 4095, 0, 255);
int blue = map(analogRead(POTI_PIN_2), 0, 4095, 0, 255);
fill_solid(leds0, NUM_LEDS, CRGB(red, green, blue));
fill_solid(leds1, NUM_LEDS, CRGB(255-red, 255-green, 255-blue));
FastLED.show(); // Update LED strip
delay(200);
}
} else if (option == 1) {
while (option == 1) {
Serial.println("O1");
FastLED.setBrightness(map(analogRead(POTI_PIN_0), 0, 4095, 0, 255));
fill_solid(leds0, NUM_LEDS, CRGB::White);
fill_solid(leds1, NUM_LEDS, CRGB::White);
FastLED.show(); // Update LED strip
delay(map(analogRead(POTI_PIN_1), 0, 4095, 10, 1000));
fill_solid(leds0, NUM_LEDS, CRGB::Black);
fill_solid(leds1, NUM_LEDS, CRGB::Black);
FastLED.show(); // Update LED strip
delay(map(analogRead(POTI_PIN_2), 0, 4095, 10, 1000));
}
} else if (option == 2){
}
}