雙機通信仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
全部資料51hei下載地址:
雙機通信16按鍵兩位顯示.zip
(68.83 KB, 下載次數: 56)
2018-6-12 10:19 上傳
點擊文件名下載附件
yaomima
單片機源碼:
- #include<reg51.h>
- unsigned char code num[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e}; //共yang數碼管
- unsigned char i;
- #define shuchu0 P0
- #define shuchu2 P2
- void main(void)
- {
- while(1){
- unsigned char temp=0;
- TMOD=0x20;
- TH1=0xfd;
- TL1=0xfd;
- SCON=0x50;
- PCON=0x00;
- TR1=1;
- while(1)
- {
- while(RI==0);
- RI=0;
- temp=SBUF;
- i=temp;
- if(i<=9)
- {
- shuchu0 = num[0];
- shuchu2 = num[i];
- }
- else
- {
- i=i-10;
- shuchu0 = num[1];
- shuchu2 = num[i];
- }
- }
- }
- }
復制代碼 |