|
51按鍵計數(shù)器,你值得擁有,代碼可以編譯通過下載
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
單片機(jī)源程序如下:
- #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;
- }
復(fù)制代碼
所有資料51hei提供下載:
51按鍵計數(shù)器.rar
(46.73 KB, 下載次數(shù): 42)
2018-2-24 09:41 上傳
點擊文件名下載附件
|
|