Boe-Bot IR code from manual for roaming doesn't work help!!
dasmith6975
Posts: 6
built the boe-bot with ir sensor for navigation and used code from manual but it doesn't work, anyone know why?
Comments
'
[ Title ]
' Robotics with the Boe-Bot - RoamingWithIr.bs2
' Adapt RoamingWithWhiskers.bs2 for use with IR object detectors.
' {$STAMP BS2} ' Stamp directive.
' {$PBASIC 2.5} ' PBASIC directive.
DEBUG "Program Running!"
'
[ Variables ]
irDetectLeft VAR Bit
irDetectRight VAR Bit
pulseCount VAR Byte
'
[ Initialization ]
FREQOUT 4, 2000, 3000 ' Signal program start/reset.
'
[ Main Routine ]
DO
FREQOUT 8, 1, 38500 ' Store IR detection values in
irDetectLeft = IN9 ' bit variables.
FREQOUT 2, 1, 38500
irDetectRight = IN0
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
GOSUB Back_Up ' Both detect obstacle
GOSUB Turn_Left ' Back up & U-turn (left twice)
GOSUB Turn_Left
ELSEIF (irDetectLeft = 0) THEN ' Left detects
GOSUB Back_Up ' Back up & turn right
GOSUB Turn_Right
ELSEIF (irDetectRight = 0) THEN ' Right detects
GOSUB Back_Up ' Back up & turn left
GOSUB Turn_Left
ELSE ' None detect
GOSUB Forward_Pulse ' Apply a forward pulse
ENDIF ' and check again
LOOP
'
[ Subroutines ]
Forward_Pulse: ' Send a single forward pulse.
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20
RETURN
Turn_Left: ' Left turn, about 90-degrees.
FOR pulseCount = 0 TO 20
PULSOUT 13, 650
PULSOUT 12, 650
PAUSE 20
NEXT
RETURN
Turn_Right:
FOR pulseCount = 0 TO 20 ' Right turn, about 90-degrees.
PULSOUT 13, 850
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
Back_Up: ' Back up.
FOR pulseCount = 0 TO 40
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
+1. Sensors (m)aligned and working properly? Servos centered? New batteries? If all else fails, add some debug statements in your code to monitor sensor output and program flow.
It keeps the code formated to see if there are the spaces needed in the code.
As the resistor value increases the LED gets dimmer and the detection distance drops.
Try walking up to your BOE-Bot and put something in front of it to see if it's near-sighted.
Amanda