int seg7_pin[]={2,3,4,5,6,7,8};
char seg7_table[]={~0xc0,~0xf9,~0xa4,~0xb0,~0x99,~0x92,~0x82,~0xf8,~0x80,~0x90};
void setup()
{
for(int i=0;i<7;i++)
{
pinMode(seg7_pin[i],OUTPUT);
digitalWrite(seg7_pin[i],LOW);
}
}
void loop()
{
for(int j=0;j<7;j++)
{
out(seg7_table[j]);
delay(500);
}
}
void out(byte data)
{
for(int k=0;k<7;k++)
{
if(data%2==0)digitalWrite(seg7_pin[k],LOW);
else digitalWrite(seg7_pin[k],HIGH);
data=data/2;
}
}
沒有留言:
張貼留言