#include <FastLED.h>
#define NUM_LEDS 5
#define LED_PIN 15
const int potPin = 13,
switchPin = 27;
int currentLEDS = 0,
lastLEDS = 0;
CRGB leds[NUM_LEDS];
void IRAM_ATTR function_ISR() {
// currentLEDS = analogRead(potPin);
// currentLEDS = map(currentLEDS, 0, 4095, 0, 225);
// FastLED.clear();
// for (int led = 0; led < currentLEDS; led + 2) {
// leds[led] = CRGB::CRGB::Orange;
// }
// lastLEDS = currentLEDS;
// FastLED.show();
if (digitalRead(switchPin) == HIGH) {
FastLED.clear();
digitalWrite(2, HIGH);
for (int led = 0; led < NUM_LEDS; led ++) {
leds[led] = CRGB::Orange;
}
FastLED.show();
}
else {
FastLED.clear();
FastLED.show();
digitalWrite(2, LOW);
};
}
void setup() {
// analogReadResolution(10);
FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS);
pinMode(switchPin, INPUT_PULLDOWN);
attachInterrupt(switchPin, function_ISR, CHANGE);
pinMode(2, OUTPUT);
}
void loop() {
}