#include<reg51.h>
#include "UART_H_file.h"
sbit LED=P1^0;
void main()
{
char Data_in;
UART_Init();
P1 = 0;
LED = 1;
while(1)
{
Data_in = UART_RxChar();
if(Data_in == 'F')
{
LED = 0;
UART_SendString("LED_ON");
}
else if(Data_in == 'B')
{
LED= 1;
UART_SendString("LED_OFF");
}
else
{
UART_SendString("Select proper option");
}
}
}
void UART_Init()
{
TMOD = 0x20;
TH1 = 0xFD;
SCON = 0x50;
TR1 = 1;
}
void UART_TxChar(char Data)
{
SBUF = Data;
while (TI==0);
TI = 0;
}
char UART_RxChar()
{
char dat;
while (RI==0);
RI = 0;
dat = SBUF;
return(dat);
}
void UART_SendString(char *str)
{
int i;
for(i=0;str[i]!=0;i++)
{
UART_TxChar(str[i]);
}
}