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.

Pseudocode

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.

ohh I see

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

thanks

~Matt

ping sensor
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.

**yea **

thanks

~Matt

my roverbot has basic code

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

https://www.robotshop.com/letsmakerobots/node/2744

code is available there for download

:slight_smile:

wow

thanks thats just what I was looking for

~Matt

Very nice example mate! Been

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