ROBOTC.net forums
http://www.robotc.net/forums/

Help with Pbasic parallax coding
http://www.robotc.net/forums/viewtopic.php?f=63&t=10595
Page 1 of 1

Author:  dean93 [ Sun Mar 01, 2015 3:44 pm ]
Post subject:  Help with Pbasic parallax coding

Quote:
I hate to say that I'm not much of a programer don't really have the vision for it i guess but i need help because i need to develop a program for a boe bot that finds an empty parking space and park in it, then it must back out and reverse into the parking space. The code I'm providing is only for IR and whisker sensors not really sure where to go from here. Any help is gladly appreciated thank you.


Code:
' {$STAMP BS2}
' {$PBASIC 2.5}

irDetectLeft  VAR     Bit
irDetectRight VAR     Bit
pulseCount    VAR     Byte

FREQOUT 4, 2000, 3000                        ' Signal program start/reset.

DO

  FREQOUT 8, 1, 38500                        ' Store IR detection values in
  irDetectLeft = IN9                         ' bit variables.

  FREQOUT 2, 1, 38500
  irDetectRight = IN0

IF(irDetectLeft = 0) AND (irDetectRight = 0) AND (IN5 = 0) AND (IN7 = 0) THEN
    GOSUB BACKUP                            ' Both IR pairs detect obstacle
    GOSUB LEFT                          ' Back up & U-turn (left twice)
    GOSUB LEFT
  ELSEIF (irDetectLeft = 0) THEN             ' Left IR pair detects
    GOSUB BACKUP                            ' Back up & turn right
    GOSUB RIGHT
  ELSEIF (irDetectRight = 0) THEN            ' Right IR pair detects
    GOSUB BACKUP                           ' Back up & turn left
    GOSUB LEFT
  ELSE                                  ' Both IR pairs 1, no detects
    GOSUB FORWARD                    ' Apply a forward pulse and check  again
  ENDIF
LOOP

FORWARD:
PULSOUT 13, 850            ' FORWARD
PULSOUT 12, 650
PAUSE 200

RETURN

BACKUP:
FOR pulseCount = 0 TO 20                         ' BACKWARDS
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 200
NEXT
RETURN

LEFT:
FOR pulseCount = 0 TO 20       ' LEFT ABOUT 90 DEGREES
PULSOUT 13, 650
PULSOUT 12, 650
PAUSE 200
NEXT
RETURN

RIGHT:
FOR pulseCount = 0 TO 20           ' RIGHT ABOUT 90 DEGREE
PULSOUT 13, 850
PULSOUT 12, 850
PAUSE 200
NEXT
RETURN












Author:  mightor [ Sun Mar 01, 2015 3:53 pm ]
Post subject:  Re: Help with Pbasic parallax coding

Hi there,

I think you may be a little lost. These forums are for ROBOTC. You are using a completely different programming environment. I am guessing you may find much better help at the Parallax forums: http://forums.parallax.com/forum.php

I am now locking this thread.

= Xander

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/