Shop OBEX P1 Docs P2 Docs Learn Events
HELP:Easy Bluetooth and IR detectors — Parallax Forums

HELP:Easy Bluetooth and IR detectors

IdrisIdris Posts: 7
edited 2010-03-22 02:05 in BASIC Stamp
Hello all,

I presently have hit a halt with a project. The purpose is to use the Roaming With IR from the BoeBot manual but i wish to relay the information back to the PC via the Easy Bluetooth and dongle and at the same time maneveur around the object. For example the left detector encounters and object,it would send a text· to the debug terminal saying "Object has been detected on the Left". Problem is that when the program is downloaded to the BoeBot, the ir detectors are stuck in a no object is detected state and no other function is working. Any assistance will be appreciated. Thank you.

here is the code that i am trying

'Master robot roaming with object detection and avoidance using IR. Also Bluetooth communications
' {$STAMP BS2}
' {$PBASIC 2.5}
irDetectLeft· VAR···· Bit
irDetectRight VAR···· Bit
pulseCount··· VAR···· Byte
rx··········· CON···· 2
tx··········· CON···· 0
led·········· PIN···· 5
buffer······· VAR···· Byte
'
[noparse][[/noparse] Initialization ]

'
[noparse][[/noparse] Main Routine ]
DO
· FREQOUT 8, 1, 38500······················· ' Store IR detection values in
··· irDetectLeft = IN9······················ ' bit variables.
· FREQOUT 2, 1, 38500
··· irDetectRight = IN0
SELECT buffer
· CASE $11
· IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
··· HIGH 10
··· HIGH 1
· ENDIF
··· DEBUG HOME, "obstacle in front"
··· GOSUB Reply
··· GOSUB Back_Up··························· ' Both IR pairs detect obstacle
··· GOSUB Turn_Left························· ' Back up & U-turn (left twice)
··· GOSUB Turn_Left
· CASE $12
· IF (irDetectLeft = 0) THEN·························· ' Left IR pair detects
··· HIGH 10
· ENDIF
··· DEBUG HOME, "obstacle on left"
··· GOSUB Reply
··· GOSUB Back_Up··························· ' Back up & turn right
··· GOSUB Turn_Right
· CASE $13
· IF (irDetectRight = 0) THEN························· ' Right IR pair detects
··· HIGH 1
· ENDIF
··· DEBUG HOME, "obstacle on right"
··· GOSUB Reply
··· GOSUB Back_Up··························· ' Back up & turn left
··· GOSUB Turn_Left
· CASE ELSE································· ' Both IR pairs 1, no detects
··· LOW 10
··· LOW 1
··· DEBUG HOME, "no obstacle"
··· GOSUB Reply
··· GOSUB Forward_Pulse····················· ' Apply a forward pulse
ENDSELECT··································· ' and check again
LOOP
'
[noparse][[/noparse] Subroutines ]
Reply:
· SEROUT rx,84,[noparse][[/noparse]buffer]
· RETURN
Forward_Pulse:······························ ' Send a single forward pulse.
· PULSOUT 13,850
· PULSOUT 12,650
· PAUSE 20
· RETURN
Turn_Left:·································· ' Left turn, about 90-degrees.
· FOR pulseCount = 0 TO 20
··· PULSOUT 13, 650
··· PULSOUT 12, 650
··· PAUSE 20
· NEXT
· RETURN
Turn_Right:
· FOR pulseCount = 0 TO 20·················· ' Right turn, about 90-degrees.
··· PULSOUT 13, 850
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN
Back_Up:···································· ' Back up.
· FOR pulseCount = 0 TO 40
··· PULSOUT 13, 650
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN

Post Edited (Idris) : 3/15/2010 9:34:14 PM GMT

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-03-15 21:04
    Where do you put data in buffer?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • IdrisIdris Posts: 7
    edited 2010-03-15 21:25
    i selected the buffer first and then using the case statements.would that work??
  • FranklinFranklin Posts: 4,747
    edited 2010-03-16 01:37
    My question was where do you put anything in the buffer to test it with the case statement?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • IdrisIdris Posts: 7
    edited 2010-03-16 12:03
    oh sorry abt that. i did not initialize anything in the buffer. is that the reason that the code is not going through the cases??
    also i am going through the 2nd sample code in this document and i see they have a msgIndex.would i need that to go through the cases?

    http://www.parallax.com/Portals/0/Downloads/docs/prod/comm/30085-EasyBluetooth-v1.2.pdf
  • IdrisIdris Posts: 7
    edited 2010-03-21 14:01
    any advice??
  • FranklinFranklin Posts: 4,747
    edited 2010-03-22 02:05
    Yes, fix your code and repost the code. Use the post reply button and then attach your code with the attachment manager.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.