const int potPin = A0;
void setLeds(int startPin, int endPin, int zone) {
if (startPin > endPin) return; // условие выхода
digitalWrite(startPin, startPin - 2 == zone ? HIGH : LOW);
setLeds(startPin + 1, endPin, zone); // вызов себя же
}
void setup() {
for (int i = 2; i <= 9; i++) pinMode(i, OUTPUT);
}
void loop() {
int zone = analogRead(potPin) / 128; // 0..7
setLeds(2, 9, zone);
delay(50);
}