Shop OBEX P1 Docs P2 Docs Learn Events
object avoidance bot — Parallax Forums

object avoidance bot

lobolobo Posts: 100
edited 2007-01-07 07:42 in BASIC Stamp
in the code for fastIrRoaming with the boe-bot (page 266)

the bot is using a pair of obstacle ovoidance ir's

but what if i wanted to use 3 or 4, how would i modify the code here?



IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN

Comments

  • FranklinFranklin Posts: 4,747
    edited 2006-12-16 03:09
    Write the irDetectx = X to check all the sensors. Try it with three and expand from there. That's the fun of having a boe-bot, writing your own programs to expand it's capability ( AND LEARN in the process)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • lobolobo Posts: 100
    edited 2006-12-16 06:17
    can you give me a sample code of irDectectx=X Stephe ? thank you very much for your sincere help!
  • FranklinFranklin Posts: 4,747
    edited 2006-12-16 07:38
    Top of page 267. Subroutine Check_IRs

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Special_KSpecial_K Posts: 162
    edited 2007-01-07 07:42
    this is a basic code you will have to modify it more to do what you want.. but with this you should be able to see how the code is changed.


    FREQOUT 8, 1, 38500 ' Check IR Detectors
    irDetectLeft = IN9
    FREQOUT 2, 1, 38500
    irDetectRight = IN0

    'add your new detector numbers here.
    FREQOUT 3, 1, 38500 'maybe this
    irDetectcenter = IN4 'maybe this

    ' Decide how to navigate.
    IF (irDetectLeft = 0) AND (irDetectRight = 0) AND (irDetectcenter = 0)THEN
    pulseLeft = 650
    pulseRight = 850

    ELSEIF (irDetectcenter = 0) THEN 'this would be if there is a small object in the center
    pulseLeft = 650
    pulseRight = 850

    ELSEIF (irDetectLeft = 0) THEN
    pulseLeft = 850
    pulseRight = 850
    ELSEIF (irDetectRight = 0) THEN
    pulseLeft = 650
    pulseRight = 650
    ELSE
    pulseLeft = 850
    pulseRight = 650
    ENDIF

    PULSOUT 13,pulseLeft ' Apply the pulse.
    PULSOUT 12,pulseRight
    PAUSE 15
Sign In or Register to comment.