Shop OBEX P1 Docs P2 Docs Learn Events
help — Parallax Forums

help

xianxian Posts: 2
edited 2008-01-07 01:17 in BASIC Stamp
need some help here for the boe-bot. anyone done the FollowingBoeBot.bs2 program? i dun wan it to move when it's activated but how do i do it? i try various methods..would be grateful if someone tell me how do i do it. confused.gif'

[noparse][[/noparse] Constants ]

Kpl CON -35
Kpr CON 35
SetPoint CON 2
CenterPulse CON 750
'
[noparse][[/noparse] Variables ]

freqSelect VAR Nib
irFrequency VAR Word
irDetectLeft VAR Bit
irDetectRight VAR Bit
distanceLeft VAR Nib
distanceRight VAR Nib
pulseLeft VAR Word
pulseRight VAR Word
'
[noparse][[/noparse] Initialization ]

FREQOUT 4, 2000, 3000
'
[noparse][[/noparse] Main Routine ]

DO
GOSUB Get_Ir_Distances
' Calculate proportional output.
pulseLeft = SetPoint - distanceLeft * Kpl + CenterPulse
pulseRight = SetPoint - distanceRight * Kpr + CenterPulse
GOSUB Send_Pulse

LOOP

'
[noparse][[/noparse] Subroutine - Get IR Distances ]

Get_Ir_Distances:
distanceLeft = 0
distanceRight = 0
FOR freqSelect = 0 TO 4
LOOKUP freqSelect,[noparse][[/noparse]37500,38250,39500,40500,41500], irFrequency
FREQOUT 8,1,irFrequency
irDetectLeft = IN9
distanceLeft = distanceLeft + irDetectLeft
FREQOUT 2,1,irFrequency
irDetectRight = IN0
distanceRight = distanceRight + irDetectRight
NEXT
RETURN
'
[noparse][[/noparse] Subroutine – Get Pulse ]
Send_Pulse:
PULSOUT 13,pulseLeft
PULSOUT 12,pulseRight
PAUSE 5

RETURN

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-01-05 21:34
    What do you want it to do? You are telling it to get IR distance and then move. If you want it to wait 5 seconds before moving add a pause 5000 in front of the do loop

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • xianxian Posts: 2
    edited 2008-01-07 01:17
    okay..i try it already. it can work! thanks a million.=)
Sign In or Register to comment.