【资源下载】下载地址如下1505:
https://docs.qq.com/doc/DTlRSd01BZXNpRUxl

#include <reg51.h>
#include <math.h>
sbit switch1=P0^0;
sbit switch2=P0^1;
sbit switch3=P0^2;
void delay_ms(unsigned int i)
{
unsigned char j;
for(;i>0;i--)
for(j=0;j<125;j++);
}
void main()
{
EA=1;
TMOD=0x20;
TL1=0xfd;
TH1=0xfd;
PCON=0x00;
SCON=0xd0;
TR1=1;
ES=1;
SBUF=0xff;
while(TI==0);
TI=0;
while(1)
{
delay_ms(100);
if(switch1==0)
{
TB8=1;
SBUF=0x01;
while(TI==0);
TI=0;
TB8=0;
SBUF=0x00;
while(TI==0);
TI=0;

本文介绍了一个基于51单片机的串口通信实例,通过定时器和中断实现数据发送,并展示了如何使用开关控制串口数据的发送。代码中包含了定时延时函数、主函数及串口初始化等关键部分。
754

被折叠的 条评论
为什么被折叠?



