求下图的单片机C语言程序、利用外部中断0.1实现数码管从0--9的加一或减一

2024-12-29 14:14:33
推荐回答(1个)
回答1:

#include
#define uchar unsigned chr
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar key;
void ext0() interrupt 0
{
key++;
key%=10;
}
void ext1() interrupt 2
{
dat--;
if(dat>9)dat=9;
}
main()
{
EX0=1;
EX1=1;
IT0=1;
IT1=1;
EA=1;
while(1)P2=table[dat];
}