Help with Whiskers
travisb
Posts: 2
I CANT get the whiskers to function for the boe-bot. I know I have everything wired correctly. I've been over the code several times and cant find a error. The whiskers against the 3 pins are testing ok. Can anyone help?
DEBUG "PROGRAM RUNNING"
pulseCount VAR Byte
FREQOUT 4, 2000, 3000
DO
IF (IN5 = 0) AND (IN7 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Turn_Left
ELSEIF (IN5 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Right
ELSEIF (IN7 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
ELSE
GOSUB Forward_Pulse
ENDIF
LOOP
Forward_Pulse:
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20
RETURN
Turn_Left:
FOR pulseCount = 0 TO 20
PULSOUT 13, 650
PULSOUT 12, 650
PAUSE 20
NEXT
RETURN
Turn_Right:
FOR pulseCount = 0 TO 20
PULSOUT 13, 850
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
Back_Up:
FOR pulseCount = 0 TO 40
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
DEBUG "PROGRAM RUNNING"
pulseCount VAR Byte
FREQOUT 4, 2000, 3000
DO
IF (IN5 = 0) AND (IN7 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Turn_Left
ELSEIF (IN5 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Right
ELSEIF (IN7 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
ELSE
GOSUB Forward_Pulse
ENDIF
LOOP
Forward_Pulse:
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20
RETURN
Turn_Left:
FOR pulseCount = 0 TO 20
PULSOUT 13, 650
PULSOUT 12, 650
PAUSE 20
NEXT
RETURN
Turn_Right:
FOR pulseCount = 0 TO 20
PULSOUT 13, 850
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
Back_Up:
FOR pulseCount = 0 TO 40
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
Comments
Did you ever get this working? Since I don't actually have a Boe-Bot set up right now, I hooked up a couple of continuous rotation servos on a BoE with a BS2 and wired some push button switches in place of the whiskers. When I ran your code everything seemed to work correctly. The servos ran and changed directions as the switches were pressed, though I can't really say if an actual Boe-Bot would move as you expected.
I would go back and redo the wiring (make sure you're using the right resistors), and if you're using batteries, make sure they're new.
It's a good idea to use a wall adapter instead of batteries when testing stuff on the Boe-Bot, then switch to batteries once you're sure it's working right. You can set the 'bot on a small box or block of wood or something so it doesn't run all over the place while testing.
If you have the EXACT same problem, then read what's been suggested so far and follow the suggestions (like those from nrsmac).
I have Robotics with the BoeBot V2.2 and I've looked at Figure 5-4 on page 168 and Figure 5-5 on page 169 and they both look correct. Sometimes the breadboard can have bad connections where a group of 5 holes is normally connected together. Check the voltage at the Stamp pin. It should be near 5V when the whisker switch is open (not touching) and near 0V when the whisker switch is closed.