|
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
51hei.png (32.5 KB, 下載次數(shù): 51)
下載附件
2020-4-8 14:05 上傳
單片機源程序如下:
- #include "scanf.h"
- #include "delay.h"
- #include <reg52.h>
- #include "led.h"
- #define uint unsigned int
- #define uchar unsigned char
- void key0()
- {
- liushui6();
- P0=0xff;
- }
- void key1()
- {
- liushui5();
- P0=0xff;
- }
- void key2()
- {
- led_turn();
- P0=0xff;
- }
- void key3()
- {
- liushui4();
- P0=0xff;
- }
- void key4()
- {
- liushui3();
- P0=0xff;
- }
- void key5()
- {
- liushui2();
- P0=0xff;
- }
- void key6()
- {
- liushui1();
- P0=0xff;
- }
- void key7()
- {
- P0=0x00;
- delay_ms(800);
- P0=0xff;
- }
- void scanf(void)
- {
- while(1)
- {
- while(P1==0xff);
- delay_ms(10);
- while(P1==0xff);
- switch(P1)
- {
- case 0xfe:key0();break;
- case 0xfd:key1();break;
- case 0xfb:key2();break;
- case 0xf7:key3();break;
- case 0xef:key4();break;
- case 0xdf:key5();break;
- case 0xbf:key6();break;
- case 0x7f:key7();break;
- default: break;
- }
- while(P1!=0xff);//等待鍵釋放
- }
- }
復(fù)制代碼
所有資料51hei提供下載:
實驗二.rar
(86.25 KB, 下載次數(shù): 15)
2020-4-8 11:46 上傳
點擊文件名下載附件
獨立按鍵輸入 下載積分: 黑幣 -5
|
|