const int led[]={2,3,4,5,6,7};
int i;
int j;
int k;
const int ledmap[6][6]=
{ {1,0,0,0,0,0},
{1,1,0,0,0,0},
{1,1,1,0,0,0},
{1,1,1,1,0,0},
{1,1,1,1,1,0},
{1,1,1,1,1,1}
};
void setup()
{
for(i=0;i<6;i++)
pinMode(led[i],OUTPUT);
}
void loop()
{
for(i=0;i<6;i++)
{
for(j=0;j<6;j++)
{
if(ledmap[i][j]==1)
{
digitalWrite(led[j],HIGH);
}
delay(100); //不加六個燈會一直亮
}
}
delay(1000);//停個1秒,再把led全部歸零
for(k=0;k<6;k++)
digitalWrite(led[k],LOW);
}
沒有留言:
張貼留言