Shop OBEX P1 Docs P2 Docs Learn Events
please make this beep — Parallax Forums

please make this beep

adam4adam4 Posts: 10
edited 2007-01-10 15:41 in BASIC Stamp
'
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

  • Tom WalkerTom Walker Posts: 509
    edited 2007-01-10 14:18
    I'm not sure I understand exactly what you looking for. This program only "beeps" when it first starts up (only once) when it executes the FREQOUT 4, 2000,3000 command (see the PBasic reference manual for what each parameter does). What kind of "beeping" are you wanting it to do?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • Mr. RichardMr. Richard Posts: 51
    edited 2007-01-10 15:41
    check out chapter 8 of the "What is a microcontroler?" text (it's just fun stuff)

    the book can be downloaded from parallax as a free PDF
Sign In or Register to comment.