单片机AT89C51用C语言编,两个按钮分别控制一个数码管加减数,最好用中

2025-03-12 17:37:04
推荐回答(2个)
回答1:

#include
#define uchar unsigned char
uchar distab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00}; //0到f
uchar dat;
void ext0() interrupt 0
{
dat++;
dat%=10;
P1=distab[dat];
}
ext1() interrupt 2
{
if(dat>0)dat--;
P1=disab[dat];
}
main()
{
EX0=1;
EX1=1;
IT0=1;
IT1=1;
EA=1;
while(1);
}

回答2:

外部中断,proteus 仿真