//
turn
all
the
LEDs
off:
digitalWrite(ledPins[5],
LOW);
//Turn
off
LED
#5
(pin
9)
delay(delayTime);
//wait
delayTime
millisecon
ds
digitalWrite(ledPins[4],
LOW);
//Turn
off
LED
#4
(pin
8)
delay(delayTime);
//wait
delayTime
millisecon
ds
digitalWrite(ledPins[3],
LOW);
//Turn
off
LED
#3
(pin
7)
delay(delayTime);
//wait
delayTime
millisecon
ds
digitalWrite(ledPins[2],
LOW);
//Turn
off
LED
#2
(pin
6)
delay(delayTime);
//wait
delayTime
millisecon
ds
digitalWrite(ledPins[1],
LOW);
//Turn
off
LED
#1
(pin
5)
delay(delayTime);
//wait
delayTime
millisecon
ds
digitalWrite(ledPins[0],
LOW);
//Turn
off
LED
#0
(pin
4)
delay(delayTime);
//wait
delayTime
millisecon
ds
}
/*
oneAfterAnotherLoop()
This
function
does
exactly
the
same
thing
as
oneAfterAnotherNo
Loop(),
but
it
takes
advantage
of
for()
loops
and
the
array
to
do
it
w
ith
much
less
typing.
*/
void oneAfterAnotherLoop()
{
int index;
int delayTime
= 100;
//
milliseconds
to
pause
between
LEDs
//
make
this
smaller
for
faster
switchi
ng
//
Turn
all
the
LEDs
on:
//
This
for()
loop
will
step
index
from
0
to
5
//
(putting
"++"
after
a
variable
means
add
one
to
it)
//
and
will
then
use
digitalWrite()
to
turn
that
LED
on.
for(index
= 0;
index
<= 5;
index++)
{
digitalWrite(ledPins[index],
HIGH);
delay(delayTime);
}
//
Turn
all
the
LEDs
off:
//
This
for()
loop
will
step
index
from
5
to
0
//
(putting
"
"
after
a
variable
means
subtract
one
from
i
t)
//
and
will
then
use
digitalWrite()
to
turn
that
LED
off.
for(index
= 5;
index
>= 0;
index
)
{
digitalWrite(ledPins[index],
LOW);
delay(delayTime);
}
}
Page 25 of 63