Program Arduino :
int i;
void setup() {
// initialize digital pin LED as an output.
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
for (i=1;i<=8;i++)
{
digitalWrite(i, HIGH); // turn the LED on (HIGH is the voltage level)
delay(50); // wait for 50 milisecond
digitalWrite(i, LOW); // turn the LED off (HIGH is the voltage level)
//delay(50);
}
for (i=8;i>=1;i--)
{
digitalWrite(i, HIGH); // turn the LED on (HIGH is the voltage level)
delay(50); // wait for 50 mili second
digitalWrite(i, LOW); // turn the LED on (LOW is the voltage level)
//delay(50);
}
}
No comments:
Post a Comment