#include
#define uint unsigned int
#define uchar unsigned char
uchar duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar liushui[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar num=0;
void delay(uint i)
{
while(i--);
}
/* ********************************************************************************************* */
void init(void)//初始化子函数
{
IT0=1;//设置外部中断0为边沿触发
EX0=1;//打开外部中断0
IT1=1;//设置外部中断1为边沿触发
EX1=1;//打开外部中断1
EA=1;//打开中断的总开关
}
/* ********************************************************************************************* */
main() //主函数
{
init();
while(1)
{
num++;
if(num==10)
num=0;
P1=duan[num];
delay(50000);
}
}
/* ********************************************************************************************* */
void int0(void) interrupt 0//外部中断0处理程序
{
P1=0;
delay(20000);
P1=0x00;
delay(20000);
P1=0x00;
delay(20000);
}
/* ********************************************************************************************* */
void int1(void) interrupt 2//外部中断1处理程序
{
uchar i,j;
for(i=0;i<3;i++)
{
for(j=0;j<8;j++)
{
P2=liushui[j];
delay(5000);
}
}
P2=0xff;
}
相关文章









