int potPin = A0;
int ledPins[] = {2, 3, 4, 5, 6, 7, 8};
void setup() {
for (int i = 0; i < 7; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
int potValue = analogRead(potPin);
int activeLeds = map(potValue, 0, 1023, 0, 7);
for (int i = 0; i < 7; i++) {
if (i < activeLeds) {
digitalWrite(ledPins[i], HIGH);
} else {
digitalWrite(ledPins[i], LOW);
}
}
}