通过74ls165将按键的状态串口输入到51单片机,在数码管上显示出来,每个按键对应数码管上的一段。
proteus仿真电路图如下:
#include "reg51.h"
sbit SL=P3^7 //串口接收启动端口:0->1启动。
#define LEDPORT P0;
void main()
{
unsigned char ucCount;
SCON=0x10; //设置串口模式:模式0,允许接收。
while(1)
{
SL=0;
SL=1; //启动接收。
while(RI==0);
LEDPORT=SBUF; //转存数据。
RI=0;
for(ucCount=0;ucCount<250;ucCount++);
}
}
关键字:51单片机 C编程 74LS165 串口输入『本文转载自网络,版权归原作者所有,如有侵权请联系删除』