|
- #include<reg52.h>
- #define uint unsigned int
- sbit a1=P2^6;
- sbit a2=P2^7;
- uint k=0;
- uint code dat[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
- void delay()
- {
- uint i;
- for(i=2000;i>0;i--);
- }
- void main()
- {
- EA=1;
- EX0=1;
- EX1=1;
- IT0=1;
- IT1=1;
- while(1)
- {
- P0=0;
- P0=dat[k/10];
- a2=1;
- a1=0;
- delay();
- P0=0;
- P0=dat[k%10];
- a1=1;
- a2=0;
- delay();
- }
- }
- void jiashu() interrupt 0
- {
- if(k<99)
- k=k+1;
- else
- k=0;
- }
- void jianshu() interrupt 2
- {
- if(k>0)
- k=k-1;
- else
- k=99;
- }
復制代碼 |
-
12.JPG
(197.4 KB, 下載次數: 83)
下載附件
2017-4-12 11:39 上傳
-
-
按鍵計數.zip
2017-4-12 11:39 上傳
點擊文件名下載附件
51.62 KB, 下載次數: 50
|