Code:
int ledPins[] = {0,1,2,3,4};
int led = 13;
void setup()
{
int index;
for(index = 0; index <= 4; index++)
{
pinMode(ledPins[index],OUTPUT);
}
void oneOnAtATime()
{
int index;
int delayTime = 100; // milliseconds to pause between LEDs
// make this smaller for faster switching
// step through the LEDs, from 0 to 4
for(index = 0; index <= 4; index++)
{
digitalWrite(ledPins[index], HIGH); // turn LED on
delay(delayTime); // pause to slow down
digitalWrite(led, HIGH); // turn LED on
digitalWrite(ledPins[index], LOW); // turn LED off
}
}
}
No comments:
Post a Comment