|
发表于 2023-12-1 02:30:09
|
显示全部楼层
主程序 + 两个外部中断
#include
void delay (unsigned int t);
code unsigned char sz []={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
sbit led0=P2^7;
sbit led1=P2^1;
sbit P10=P1^0;
void main ()
{
char num;
EA=1;
EX0=1;
EX1=1;
IT0=1;
IT1=1;
while(1)
{
P10=0;
for (num=0;num {
P0=sz[num];
delay(50000);
}
}
}
void delay (unsigned int t)
{
unsigned int i;
i=t;
while (i--);
}
void int0() interrupt 0
{
led0=0;
delay(50000);
led0=1;
delay(50000);
led0=0;
delay(50000);
led0=1;
delay(50000);
led0=0;
delay(50000);
led0=1;
delay(50000);
}
void int1() interrupt 2
{
led1=0;
delay(50000);
led1=1;
delay(50000);
led1=0;
delay(50000);
led1=1;
delay(50000);
} |
|