int leds[] = {8, 9, 10, 11}; //signals to the simularotr where each LED is connected to each pin
void setup()
{
for (int i = 0; i < 4; i++) //so the simulator can read what the code is doing and do a for loop
{
pinMode(leds[i], OUTPUT); //sends the signal for all LED outputs
}
}
void loop()
{
for (int step = 0; step < 4; step++) //so the simulator can read for each step of the staircase
{
for (int i = 0; i <= step; i++) //so the simulator can read what the code is doing to turn on
{
digitalWrite(leds[i], HIGH); //turns the LED(s) on for each step
}
delay(500); //leaves the LEDs on for 1/2 second
for (int i = 0; i <= step; i++) //so the simulator can read what the code is doing to turn off
{
digitalWrite(leds[i], LOW); //turns the LED(s) off for each step
}
delay(500); //leaves the LEDs off for 1/2 second
}
delay(1000); //turns all LEDs off for 1 second before the simulator restarts the process.
}