ok I am doing a remote control for my robot I wrote a code below, It seems long, Maybe you have a better idea. I am using two Potentiometer , the values of each will control the left and right motor of the robot:
'Remote control*****************
direction var word : speed var word
Loop:
If (left => 115) AND (left <= 135) AND (right => 115) AND (right <= 135) then
goto stop
If (left => 115) AND (left <= 135) AND (right <= 115) then 'left is stop, right is CCW
goto LeftstopRightCCW
If (left => 115) AND (left <= 135) AND (right => 135) then 'left is stop , right is CW
goto LeftstopRightCW
If (right => 115) AND (right <= 135) AND (right <= 115) then 'right is stop, left is CCW
goto RightstopLeftCCW
If (right => 115) AND (right <= 135) AND (right => 135) then 'right is stop , left is CW
goto RightstopLeftCW
If (left > 135) AND (right > 135) then 'Left Cw & right CW
goto LeftCWRightCW
If (left > 135) AND (right < 135) then 'Left CW & right CCW
goto LeftCWRightCCW
If (left < 135) AND (right > 135) then 'Left CCW & right CW
goto LeftCCWRightCW
If (left < 135) AND (right < 135) then 'Left CCW & right CCW
goto LeftCCWRightCCW
In brief:
'Stop '--------------------------------$69 = 01 10 10 01
'Leftwheel =stop : Rightwheel= CCW '--- $A6 = 10 10 01 10
'Leftwheel =stop : Rightwheel= CW '----- $96 = 10 01 01 10
'Leftwheel =CCW : Rightwheel= stop '---- $9a = 10 01 10 10
'Leftwheel =CW : Rightwheel= stop '----- $A5 = 10 10 01 01
'Leftwheel =CW : Rightwheel= CW '---- $66 = 01 10 01 10
'Leftwheel =CW : Rightwheel= CCW '---- $56 = 01 01 01 10
'Leftwheel =CCW : Rightwheel= CW '---- $5a = 01 01 10 10
'Leftwheel =CCW : Rightwheel= CCW '---- $65 = 01 10 01 01
Bookmarks