int led[]={2,3,4,5,6,7,8,9};
int j=0;
int x=0;
void setup() {
// put your setup code here, to run once:
for(int i=0;i<=7;i++)
{
pinMode(led[i],OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
if(x==0)
{
for(int i=0;i<=7;i++)
{
digitalWrite(led[i],LOW);
}
digitalWrite(led[j],HIGH); delay(1000);
digitalWrite(led[j],LOW);
j++;
if(j==7) x=1;
}
if(x==1)
{
for(int i=7;i>=0;i--)
{
digitalWrite(led[i],LOW);
}
digitalWrite(led[j],HIGH); delay(1000);
digitalWrite(led[j],LOW);
j--;
if(j==0) x=0;
}
}
沒有留言:
張貼留言