- #include <reg52.h>
- LED_[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
- disbuf[]={0x01,0x02,};
- void delay(unsigned char time)
- {
- unsigned char i;
- int j=0;
- for(i=time;i>0;i--)
- for(j=0;j<125;j++);
- }
- break_() interrupt 2
- {
- int i,j;
- int m=0;
- m=m+2;
- i=m%10;
- j=m/10;
- if(j!=0)
- for(j=0;j<2;j++)
- {
- P2=disbuf[j];
- P0=LED_[i];
- delay(10);
- }
- else
- {
- P2=0x01;
- P0=LED_[i];
- delay(10);
- P2=0x02;
- P0=LED_[i];
- }
- }
- void main()
- {
- P0=0x3f;
- P2=0x01;
- EA=1;
- EX1=1;
- IE1=1;
- IT1=1;
- while(1);
- }
复制代码 |