基于单片机四机多机通信仿真系统设计-资料
【资源下载】下载地址如下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;