|
- #include<reg52.h>
- sbit L5=P1^5;
- int n =0 ;
- unsigned char table[] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
- void Delay(unsigned int xms)
- {
- unsigned char i, j;
- while(xms--)
- {i = 12;
- j = 169;
- do
- {
- while (--j);
- } while (--i);}
-
- }
- void INT0_init()
- {
- EA = 1;
- EX0 = 1;
- IT0 = 1;
- }
- void display(int num)
- {
- P2 = 0x70;
- P0 = table[num/10000];
- P2 = 0xB0;
- P0 = table[num%10000/1000];
- P2 = 0xD0;
- P0 = table[num%1000/100];
- P2 = 0xE0;
- P0 = table[num%100/10];
- }
- void main()
- {
-
- P1 = 0xFF;
- INT0_init();
- while(1)
- {
- P1 = 0xff;
- display(n);
- }
- }
- void INT01() interrupt 0
- {
- n++;
- }
复制代码 |
|