const int ledPins[8] = {13, 12, 14, 27, 26, 25, 33, 32};
const int potPin = 34;
int currentLed = 0;
void setup() {
for (int i = 0; i < 8; i++) {
pinMode(ledPins[i], OUTPUT);
}
pinMode(potPin, INPUT);
}
void loop() {
int potValue = analogRead(potPin);
int delayTime = map(potValue, 0, 4095, 500, 20);
for (int i = 0; i < 8; i++) {
digitalWrite(ledPins[i], LOW);
}
digitalWrite(ledPins[currentLed], HIGH);
delay(delayTime);
currentLed++;
if (currentLed >= 8) {
currentLed = 0;
}
}
Loading
esp32-devkit-c-v4
esp32-devkit-c-v4