Parallax Boe-Bot Student Manual page 206

Hide thumbs Also See for Boe-Bot:
Table of Contents

Advertisement

Page 192 · Robotics with the Boe-Bot
' Robotics with the Boe-Bot - CirclingWithWhiskerInput.bs2
' Move in 1 yard circle, increase/decrease radius in response
' to whisker presses, one whisker increases, one decreases.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
' -----[ Variables/Initialization ]------------------------------------
pulseWidth
toneFreq
pulseWidth = 716
toneFreq = 4000
' -----[ Main Routine ]------------------------------------------------
DO
PULSOUT 13, 850
PULSOUT 12, pulseWidth
PAUSE 20
IF (IN5
= 0) THEN
IF (pulseWidth <= 845) THEN
pulseWidth = pulseWidth + 5
toneFreq = toneFreq + 100
FREQOUT 4, 100, toneFreq
ENDIF
ELSEIF (IN7
IF (pulseWidth >= 655) THEN
pulseWidth = pulseWidth - 5
toneFreq = toneFreq - 100
FREQOUT 4, 100, toneFreq
ENDIF
ENDIF
LOOP
VAR
Word
VAR
Word
= 0) THEN
' Stamp directive.
' PBASIC directive.
' Signal sent to servo
' Frequency of beeping tone
' Found in Ch4 to make 1y circle
' Beginning tone is 4 kHz
' Pulse servos in circular path
' 12 slower than 13 so it arcs
' Left whisker makes circle
' smaller, down to servo max
' pulseWidth of 850.
' Play tone as indicator.
' Right whisker makes circle
' larger, down to servo min
' pulseWidth of 650.
' Play tone as indicator.

Advertisement

Table of Contents
loading

Table of Contents