byte ledPin[] = {6, 7, 8, 9, 10, 11, 12};
int direction = 1;
int currentLED = 0;
unsigned long changeTime;
#define pot A5
void setup() {
// put your setup code here, to run once:
for(int x = 0; x < 7; x++) {
pinMode(ledPin[x], OUTPUT);
}
changeTime = millis();
pinMode(pot, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int valuePot = analogRead(pot);
Serial.println(valuePot);
if((millis() - changeTime) > valuePot) {
changeLED();
changeTime = millis();
}
}
void changeLED() {
for(int x = 0; x < 7; x++) {
digitalWrite(ledPin[x], LOW);
}
digitalWrite(ledPin[currentLED], HIGH);
currentLED += direction;
if(currentLED == 6) { direction = -1; }
if(currentLED == 0) { direction = 1; }
}