单片机源程序如下:
- #include
- unsigned char code table[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
- unsigned char count;
- void delay(unsigned int time)
- {
- unsigned int j = 0;
- for(;time>0;time--)
- for(j=0;j<125;j++);
- }
- key0() interrupt 0
- {
- delay(10);
- count++;
- if(count==100)
- count=0;
- P0=table[count/10];
- P2=table[count%10];
- }
- void display_mode()
- {
- P2 = 0x00;
- delay(500);
- P2 = 0x3f;
- delay(500);
- }
- void main(void)
- {
- EA = 1;
- EX0 = 1;
- IT0 = 1;
- P0 = table[0];
- P2 = table[0];
- display_mode();
- while(1)
- {
-
- }
- }