Robot Receiver side
Robot Receiver Side:
#include<reg51.h>
#include<stdio.h>
sbit LM1=P0^4;
sbit LM2=P0^5;
sbit RM1=P0^6;
sbit RM2=P0^7;
unsigned char ch=0;
void delay(unsigned int t);
void Motor_Forward_Direction()
{
LM1=0;
LM2=1;
RM1=0;
RM2=1;
}
void Motor_Reverse_Direction()
{
LM1=1;
LM2=0;
RM1=1;
RM2=0;
}
void Motor_Left_Direction()
{
LM1=0;
LM2=1;
RM1=1;
RM2=0;
}
void Motor_Right_Direction()
{
LM1=1;
LM2=0;
RM1=0;
RM2=1;
}
void Motor_Off()
{
LM1=0;
LM2=0;
RM1=0;
RM2=0;
}
void delay(unsigned int t)
{
unsigned int i,j;
for(i=0;i<=t;i++)
for(j=0;j<=498;j++);
}
void main()
{
P0=P1=0×00;
P2=0xff;
while (1)
{
ch=P2;
delay(10);
if (ch==0xFE)
{
Motor_Forward_Direction();
P1=P2=0xff;
}
else if (ch==0xFD)
{
Motor_Reverse_Direction();
P1=P2=0xff;
}
else if (ch==0xFB)
{
Motor_Left_Direction();
P1=P2=0xff;
}
else if (ch==0xF7)
{
Motor_Right_Direction();
P1=P2=0xff;
}
else if (ch==0xF0)
{
Motor_Off();
P1=P2=0xff;
}
P1=P2=0xff;
}
P1=P2=0xff;
}