programming help please
GirlNeedsHelpASAP
Posts: 1
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.
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
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.
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.