Shop OBEX P1 Docs P2 Docs Learn Events
need help coding for the car — Parallax Forums

need help coding for the car

GotchaSukkaGotchaSukka Posts: 3
edited 2006-06-02 19:16 in BASIC Stamp
using pbasic, and a basic stamp 2 , where we have to make a car travel in a straight line for 2m.

my car starts of going in a straight line and then it travels off to the left. i have to make it go in a straight line. to compromise for that i have to turn both on then the car will start of straight, then turn 1 motor off so the car aligns to be straight again, and then have them both go so it travels in a straight line.

I need help with the coding in this task


this is my example code:


'make robot go in a straight line
' {$STAMP BS2}
' {$PBASIC 2.5}

LOW 12································ 'the motor is stopped for 10 s
LOW 13
LOW 14
LOW 15
PAUSE 10000

LOW 12································ 'makes the motor go straight for 5 s
HIGH 13
LOW 14
HIGH 15
PAUSE 5000

······································· 'car staops for 10 seconds
LOW 12
LOW 13
LOW 14
LOW 15
PAUSE 10000
counter VAR Byte
····································· 'one motor will run and count to 10 then
FOR counter = 1 TO 10················ 'the car will turn right
DEBUG ? counter
LOW 12
HIGH 13
LOW 14
LOW 15
PAUSE 10000
NEXT
DEBUG "all done"

LOW 12··············································'car will continue·going in a straight line
HIGH 13············································ 'for 10 seconds
LOW 14
HIGH 15
PAUSE 10000

LOW 12
LOW 13·············································· 'car will stop
LOW 14
LOW 15

Comments

  • GotchaSukkaGotchaSukka Posts: 3
    edited 2006-06-02 15:53
    can someone edit this coding so the car will travel in a straight line.
  • BeanBean Posts: 8,129
    edited 2006-06-02 16:41
    It appears that one of your motors is faster than the other.
    I'd say you've already found the solution. Just run one motor a little longer than the other.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com


    COMING SOON "SD DATA LOGGER" www.sddatalogger.com

    "I reject your reality, and substitute my own." Mythbusters
    ·
  • FranklinFranklin Posts: 4,747
    edited 2006-06-02 19:16
    You could also add encoders to the wheels and count revolutions so the car goes straight, (if the wheels are the same size.

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