#include<reg51.h>
#include "UART_H_file.h"
sbit motrf=P1^3;
sbit motrb=P1^4;
sbit motlf=P1^5;
sbit motlb=P1^6;
void main()
{
char Data_in;
UART_Init();
while(1)
{
Data_in = UART_RxChar(); /* receive char serially */
if(Data_in == 'F')
{
motrf=1;
motrb=0;
motlf=1;
motlb=0;
}
else if(Data_in == 'B')
{
motrf=0;
motrb=1;
motlf=0;
motlb=1;
}
else if(Data_in == 'R')
{
motrf=0;
motrb=1;
motlf=1;
motlb=0;
}
else if(Data_in == 'L')
{
motrf=1;
motrb=0;
motlf=0;
motlb=1;
}
else if(Data_in == 'S')
{
motrf=0;
motrb=0;
motlf=0;
motlb=0;
}
}
}
void UART_Init()
{
TMOD = 0x20;
TH1 = 0xFD;
SCON = 0x50;
TR1 = 1;
}
char UART_RxChar()
{
char dat;
while (RI==0);
RI = 0;
dat = SBUF;
return(dat);
}