AT89C51-按钮控制数码管显示

include”reg51.h”
sbit button=P3^0;
void delay(unsigned int n)
{
unsigned int i;
unsigned int j;
for(j=0;j<n;j++)
{
for(i=0;i<125;i++)
{}
}
}
main()
{ unsigned int b;
unsigned char a[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x02,0xf8,0x80,0x90};
while(1)
{ if(button==0)
{
for(b=0;b<10;b++)
{
while(button==0)
{
P2=a[b];
delay(20);
}
while(button==1)
{
}
}
}
}
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注