View unanswered posts | View active topics It is currently Tue Dec 18, 2018 12:53 pm






This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Help with Pbasic parallax coding 
Author Message
Rookie

Joined: Sun Mar 01, 2015 3:34 pm
Posts: 1
Post 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













Sun Mar 01, 2015 3:44 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post 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

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Mar 01, 2015 3:53 pm
Profile WWW
Display posts from previous:  Sort by  
This topic is locked, you cannot edit posts or make further replies.   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.