0~9 9~0閃爍顯示
*/
int i;
int j;
const char num[]={0xc0,0xFF,0xf9,0xFF,0xa4,0xFF,0xb0,0xFF,0x99,0xFF,0x92,0xFF,0x82,0xFF,0xf8,0xFF,0x80,0xFF,0x90};
const int seg[]={2,3,4,5,6,7,8,9};
void setup()
{
// put your setup code here, to run once:
for(i=0;i<8;i++)
{
pinMode(seg[i],OUTPUT);
}
}
void loop()
{
// put your main code here, to run repeatedly:
for(j=0;j<19;j++)
{
output(num[j]); delay(1000);
}
for(j=18;j>=0;j--)
{
output(num[j]); delay(1000);
}
}
void output(byte data)
{
for(i=0;i<8;i++)
digitalWrite(seg[i],bitRead(~data,i));
}
沒有留言:
張貼留言