You are on page 1of 3

FORWARD Rotation

Only Wheel

Motor 2
ON In
Clock

Motor 1:
M11=1;
M12=0

Motor 1
ON In
Clock

Motor 2:
M21=1;
M22=0

Only Wheel

Motor 2 ON In Anti-Clock

BACKWARD Rotation
Motor 1
ON In Anti-Clock

Motor 1:
M11=0;
M12=1
Motor 2:
M21=0;
M22=1

Motor 2 ON In Clock

Only Wheel

LEFT Rotation

Motor 1
OFF
Motor 1:
M11=0;
M12=0
Motor 2 OFF

Only Wheel

Right Rotation

Motor 1
ON In
Clock

Motor 2:
M21=1;
M22=0

Motor 1:
M11=1;
M12=0
Motor 2:
M21=0;
M22=0

Code:
#include<reg51.h>
sbit M11=P2^0;
sbit M12=P2^1;
sbit M21=P2^2;
sbit M22=P2^3;
sbit sw1=P1^0;
sbit sw2=P1^1;
sbit sw3=P1^2;
sbit sw4=P1^3;
void main()
{
Sw1=sw2=sw3=sw4=0;
M11=M12=M21=M22=0;
while(1)
{
// For FORWARD Rotation
if(sw1==1)
{
M11=M21=1;

M12=M22=0;

}
// For BACKWARD Rotation
if(sw2==1)
{
M11=M21=0;

M12=M22=1;

}
// For LEFT Rotation
if(sw3==1)
{
M21=1;

M11=M12=M22=0;

}
// For RIGHT Rotation
if(sw4==1)
{
M11=1;
}
}
}

M12=M21=M22=0;

You might also like