Shop OBEX P1 Docs P2 Docs Learn Events
programming help please — Parallax Forums

programming help please

edited 2007-12-14 05:34 in Robotics
Hi,

I'm trying to program a boebot with a ping sensor, soundpal & accelerometer.
I have all the programs working seperately that I got from the part site. But I cannot figure out how to get them all to work in one cohesive program.

Basically I want the boebot to go straight until it is 4 inches from an obstacle, make a noise (siren), try going left then right if path still blocked, make a noise (charge) when clear path is found. It should be a simple program, but I've spent over 4 hours trying everything I can think of.

The closest I've come is using subroutines where i tell the boebot to go straight for a certain amount of time then check the distance for obstacles, but that isn't really what I want. :-\

Please help.
Thank you.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-13 06:03
    You will have to post your program as an attachment so we can see what you're doing. Just a description of what you want to do won't help. You'll also have to describe what happens when you try to run the program.

    You will need to divide the program up into subroutines as you've started to do. It actually makes things easier and helps with debugging.

    You'll need to get each part working separately if you haven't done so already, like move forward until it's 4 inches from an obstacle.
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2007-12-14 05:34
    Your logic should be something like:

    Main:
    check to see if object in the way
    if it is goto avoid
    Forward:
    serout to move forward
    check to see if object in the way
    if it is goto avoid
    pause
    goto Forward

    avoid:
    make noise
    serout to turn left
    check the path
    if clear sound and goto forward
    serout to turn right 'original direction
    serout to turn right
    check the path
    if clear sound and goto forward


    Keep in mind, BoE and the Basic stamps don't have interrupts (except the SX, I believe) so you will have to actively poll as your moving by looping like forward above does. Remember that the servos need the pauses anyway, just use some or all of the time you would be pausing and use it to check the ping and deciding if you need to branch. I've not used the ping or sound modules, nor do I know what pins your using. Posting your existing code could help us to help you.
Sign In or Register to comment.