Let's Make Robots!

help with aparallax ultrasonic distance sensor on arduino

I just got my parallax ultrasonic distance sensor (#28015) and I have the "test code" running as I type, but how do I use it to warn my robot of walls?

P.S I am using an Arduino diecimila.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
I found some sample code on arduino.cc  search for ping ultrasonic sensor and you'll find a ping and l.e.d. example. I used it to interface the ping to the motor driver and arduino. hope this helps.

thanks

~Matt

DOn't know Arduino, but somethiing like :

if (ultrasoundValue < presetDistance ) then GoTheOtherDirection

might be a start. 

Just relate what distance to an objact you feel is safe for the robot to get within, then use that value to change what the robot is doing. You mihgt have code that sets the robot going forward initially, andin its travels, the distance measured to obstacles starts getting smaller. So you would have a set value to trigger the robot to either turn away, or even back away from the detected whatever.

 for some reason it sounded impossiblly hard to figure out  in my head lol

thanks

~Matt

my roverbot has basic code for using a parallax ping sensor to navigate and avoid obstacles

http://letsmakerobots.com/node/2744

code is available there for download

:-)

Very nice example mate! Been wondering if there is any Arduino which supports c++ compiled code instead of vanilla-c. I'm much more used to the earlier, thus avoid using the latter.

Thanks again for the code example!
-Jaime Garcia Dias @ ac to dc converter

You might be better off just programming AVRs with an AVRISP if that's how you want to roll, but what you're asking is kind of like wanting to know if there's a flex fuel version of the Chevy Volt.

thanks thats just what I was looking for

~Matt