byte ledPins[] = {15, 2, 4, 5, 18, 19, 21, 12, 26, 25};
int ledDelay;
int direction = 1;
int currentLED = 0;
unsigned long changeTime;
int potPin = 13;
void setup() {
for (int x=0; x<10; x++)
{
pinMode(ledPins[x], OUTPUT);
}
changeTime = millis();
Serial.begin(115200);
}
void loop() {
ledDelay = analogRead(potPin)/4.095;
Serial.println(ledDelay);
if((millis() - changeTime) > ledDelay) {
changeLED();
changeTime = millis();
}
}
void changeLED() {
for (int x=0; x<10; x++)
{
digitalWrite(ledPins[x], LOW);
}
digitalWrite(ledPins[currentLED], HIGH);
currentLED += direction;
if (currentLED == 9)
{
direction = -1;
}
if (currentLED == 0){
direction = 1;
}
}