菜鸟求助51单片机之间开关信号传输问题
时间:10-02
整理:3721RD
点击:
发送单片机
#include"reg51.h"
#define uint unsigned int
#define uchar unsigned char
void main(void)
{
uchar i=0;
TMOD=0x20;
TH1=0xFF;
TL1=0xFF;
SCON=0x40;
PCON=0x80;
TR1=1;
P1=0xFF;
while(1)
{
while(P1==0xFF);
i=P1;
SBUF=i;
while(TI==0);
TI=0;
while(P1!=0xFF);
}
}
接受单片机
#include"reg51.h"
#define uint unsigned int
#define uchar unsigned char
void main(void)
{
uchar i=0;
TMOD=0x20;
TH1=0xFF;
TL1=0xFF;
SCON=0x50;
PCON=0x80;
TR1=1;
while(1)
{
while(RI==0);
RI=0;
i=SBUF;
P1=i;
}
我现在只做到p1开关信号传输,还想让P0、P2、P3也同时进行信号传输,求大神指点,应该怎么编程,菜鸟求具体
#include"reg51.h"
#define uint unsigned int
#define uchar unsigned char
void main(void)
{
uchar i=0;
TMOD=0x20;
TH1=0xFF;
TL1=0xFF;
SCON=0x40;
PCON=0x80;
TR1=1;
P1=0xFF;
while(1)
{
while(P1==0xFF);
i=P1;
SBUF=i;
while(TI==0);
TI=0;
while(P1!=0xFF);
}
}
接受单片机
#include"reg51.h"
#define uint unsigned int
#define uchar unsigned char
void main(void)
{
uchar i=0;
TMOD=0x20;
TH1=0xFF;
TL1=0xFF;
SCON=0x50;
PCON=0x80;
TR1=1;
while(1)
{
while(RI==0);
RI=0;
i=SBUF;
P1=i;
}
我现在只做到p1开关信号传输,还想让P0、P2、P3也同时进行信号传输,求大神指点,应该怎么编程,菜鸟求具体