'''
I've made a row of LEDs pins 2-7, I've gotten them to all turn on and then reset back and forth. But it seems to reset too fast, the second last LED turns on only for a fraction of a second, and the last doesn't seem to turn on at all.
In my mind I'm thinking.
If led 7 is on for 100ms, led = 2
To allow for the program to not reset so quick, how would I do this? And is there a better way?
'''
<
unsigned long previousTime = 0;
int led = 2;
long interval = 500;
void setup() {
for (int x = 2; x < 8; x++) {
pinMode(x, OUTPUT);
}
}
void loop() {
unsigned long currentTime = millis();
if (currentTime - previousTime > interval) {
previousTime = currentTime;
digitalWrite(led, HIGH);
led++;
if (led == 7) {
for (int x = 2; x < 8; x++) {
digitalWrite(x, LOW);
}
led = 2;
previousTime = currentTime;
}
}
}