#include <FastLED.h>
#define NUM_LEDS 12
#define DATA_PIN 6
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(115200);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
leds[0] = CRGB::Red;
leds[1] = CRGB::Red;
leds[2] = CRGB::Red;
leds[3] = CRGB::Red;
leds[4] = CRGB::Red;
leds[5] = CRGB::Red;
leds[6] = CRGB::Red;
leds[7] = CRGB::Red;
leds[8] = CRGB::Red;
leds[9] = CRGB::Red;
leds[10] = CRGB::Red;
leds[11] = CRGB::Red;
leds[12] = CRGB::Red;
FastLED.show();
delay(1500);
FastLED.clear();
}
void loop() {
int pot = analogRead(A6);
Serial.println(pot);
int numLeds = map(pot, 0, 1023, 0, NUM_LEDS);
// First, clear the existing led values
FastLED.clear();
for(int led = 0; led < numLeds; led++) {
leds[led] = CRGB::Red;
}
FastLED.show();
}