仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
51hei.png (35.67 KB, 下載次數: 30)
下載附件
2022-3-11 17:10 上傳
單片機源程序如下:
- #include<reg51.h>
- #define uint unsigned int
- #define uchar unsigned char
- uchar j;
- uchar t;
- uint n;
- const uchar tab[]={0xde,0xfd,0xfb,0xf7,0xef,0xbf};
- void delay(uint n)
- {uint i;
- for(i=0;i<n;i++);
- }
- void main(void)
- {uchar key;
- P0=0x7f;
- P1=0xff;
- while(1)
- {while(P1==0xff);
- delay(2500);
- while(P1==0xff);
- key=P1;
- switch(key)
- {case 0xfe: P0=tab[0];break;
- case 0xfd: P0=tab[1];break;
- case 0xfb:P0=tab[2];break;
- case 0xf7: P0=tab[3];break;
- case 0xef:P0=tab[4];break;
- case 0xdf:P0=tab[5];break;
- }}
- }
-
復制代碼
51hei.png (11.13 KB, 下載次數: 23)
下載附件
2022-3-11 17:11 上傳
Keil代碼與Proteus仿真下載:
新建 51hei壓縮 ZIP 文件.zip
(31.42 KB, 下載次數: 13)
2022-3-11 16:24 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|