please make this beep
adam4
Posts: 10
'
Title
' Robotics with the Boe-Bot - MotionActivatedBoeBot.bs2
' Boe-Bot starts roaming when hand is waved in front of IR detectors.
' {$STAMP BS2}
' {$PBASIC 2.5}
'
Variables
irDetectLeft VAR Bit ' Variable Declarations
irDetectRight VAR Bit
pulseLeft VAR Word
pulseRight VAR Word
'
Initialization
DEBUG "Program Running!"
FREQOUT 4, 2000, 3000 ' Signal program
start/reset.
Chapter 7: Navigating with Infrared Headlights · Page 265
'
Main Routine
Main:
' Loop until something is detected
DO
GOSUB Check_IRs
LOOP UNTIL (irDetectLeft = 0) OR (irDetectRight = 0)
' Now start roaming -- this code from FastIrRoaming.bs2
DO
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
pulseLeft = 650 ' Both detect
pulseRight = 850 ' Back up
ELSEIF (irDetectLeft = 0) THEN ' Left detect
pulseLeft = 850 ' Turn right
pulseRight = 850
ELSEIF (irDetectRight = 0) THEN ' Right detect
pulseLeft = 650 ' Turn left
pulseRight = 650
ELSE ' Nothing detected
pulseLeft = 850 ' Go forward
pulseRight = 650
ENDIF
PULSOUT 13, pulseLeft ' Apply the pulse.
PULSOUT 12, pulseRight
PAUSE 15
GOSUB Check_IRs ' Check IRs again
LOOP
'
Subroutines
Check_IRs:
FREQOUT 8, 1, 38500 ' Check IR Detectors
irDetectLeft = IN9
FREQOUT 2, 1, 38500
IrDetectRight = IN0
RETURN
make this beep different tones
Title
' Robotics with the Boe-Bot - MotionActivatedBoeBot.bs2
' Boe-Bot starts roaming when hand is waved in front of IR detectors.
' {$STAMP BS2}
' {$PBASIC 2.5}
'
Variables
irDetectLeft VAR Bit ' Variable Declarations
irDetectRight VAR Bit
pulseLeft VAR Word
pulseRight VAR Word
'
Initialization
DEBUG "Program Running!"
FREQOUT 4, 2000, 3000 ' Signal program
start/reset.
Chapter 7: Navigating with Infrared Headlights · Page 265
'
Main Routine
Main:
' Loop until something is detected
DO
GOSUB Check_IRs
LOOP UNTIL (irDetectLeft = 0) OR (irDetectRight = 0)
' Now start roaming -- this code from FastIrRoaming.bs2
DO
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
pulseLeft = 650 ' Both detect
pulseRight = 850 ' Back up
ELSEIF (irDetectLeft = 0) THEN ' Left detect
pulseLeft = 850 ' Turn right
pulseRight = 850
ELSEIF (irDetectRight = 0) THEN ' Right detect
pulseLeft = 650 ' Turn left
pulseRight = 650
ELSE ' Nothing detected
pulseLeft = 850 ' Go forward
pulseRight = 650
ENDIF
PULSOUT 13, pulseLeft ' Apply the pulse.
PULSOUT 12, pulseRight
PAUSE 15
GOSUB Check_IRs ' Check IRs again
LOOP
'
Subroutines
Check_IRs:
FREQOUT 8, 1, 38500 ' Check IR Detectors
irDetectLeft = IN9
FREQOUT 2, 1, 38500
IrDetectRight = IN0
RETURN
make this beep different tones
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
the book can be downloaded from parallax as a free PDF