int led_pin[]={2,3,4,5,6,7,8,9};
char led_table[]={0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
void setup()
{
Serial.begin(9600);
for(int i=0;i<8;i++)
{
pinMode(led_pin[i],OUTPUT);
digitalWrite(led_pin[i],LOW);
}
}
void loop()
{
for(int j=0;j<16;j++)
{
out(led_table[j]);
Serial.println(j);
delay(500);
}
}
void out(byte data)
{
for(int k=0;k<8;k++)
{
if(data%2==0)digitalWrite(led_pin[k],LOW);
else digitalWrite(led_pin[k],HIGH);
data=data/2;
}
}
沒有留言:
張貼留言