WP_20140619_002.jpg (341869Bytes)
WP_20140619_004.jpg (382355Bytes)
Schermafbeelding_2014-06-19_om_15.15.34.png (155615Bytes)
Hello everyone!
i've made a robot but the servo (a Standard Servo from Parallax) I use doesn't work, it turns all the time to one side, even if i don't use it!
I connected it to a 20M2, the servo does work when the robot isn't moving but from the moment it moves, the servo turns.
Here's the code:
symbol LTPWM =C.2
symbol RTPWM =C.3
symbol LTDir =C.1
symbol RTDir =C.4
symbol IR =C.7
symbol RServo = B.0
;setup
servo RServo, 145
pause 1500
high RTDir ;by default forward
high LTDir
;wait some seconds
nap 8
;main 1
do
;measure front view
readadc IR, b0
;if there is an object in front, then look left and right
if b0 >105 then
low LTPWM
low RTPWM
servopos RServo, 40
pause 1500
readadc IR, b1
servopos RServo, 220
pause 1500
readadc IR, b2
servopos RServo, 145
;choose the best direction, if both directions are good, then take by default the left direction
if b1>b2 then
low LTDir
high RTPWM
high LTPWM
pause 750
high LTDir
low RTPWM
low LTPWM
else
low RTDir
high LTPWM
high RTPWM
pause 750
high RTDir
low LTPWM
low RTPWM
endif
;if there is no object in front, then go forward
else
high LTPWM
high RTPWM
endif
loop
;compiler commands
#PICAXE 20M2
Here are some pictures:
The upper left connection is the servo, the bottom left is the analogue sensor and the in the bottom right are the connections for the Dagu Rover 5 Motor Driver Board.