const int LED_PINS[] = {9, 8, 7, 6, 5, 4, 3, 2};
const int POT_PIN = A0;
void setup() {
Serial.begin(115200);
for (int ledPin = 0; ledPin < 8; ledPin++) {
pinMode(LED_PINS[ledPin], OUTPUT);
}
Serial.println("Turn the knob!");
}
void loop() {
int potValue = analogRead(POT_PIN);
for (int step = 0; step < 8; step++) {
digitalWrite(LED_PINS[step], LOW);
if (potValue > (128 * (step + 1)) - 64) digitalWrite(LED_PINS[step], HIGH);
}
}