NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.7

tehcereal:
Hello,
First of all thank your published work.
I got my HC SR04 today and searched on the internet how to get all working. I came across your library and another source from trollmaker.com (I have seen someone posted it before) It worked flawlessly. After that I wanted to try your library. I wired all the same using pins 12 and 11 but all I got in serial monitor was junk all in one row.
I used your sketch in the example menu.
I have a UNO r3 clone and using the newest arduino IDE
I'm a beginner so please be patient :grin:

Did you specify the correct BAUD rate as set in the sketch? The NewPing example sketches uses 115200 while I believe the Trollmaker sketch uses 9600 BAUD. If you don't select the correct speed as set in the sketch, you'll get garbage. You could also set the BAUD rate in the NewPing sketch to 9600 as well, just as long as you set the same speed both in your sketch and in the serial monitor you will see the results.

Also, with NewPing you can use just one Arduino pin instead of two. So, you can wire both the trigger and echo to Arduino pin 10, for example, which would look something like this example sketch:

http://code.google.com/p/arduino-new-ping/wiki/NewPing_Single_Pin_Sketch

Also, I would not suggest using the Trollmaker example as a basis for a sketch; There's several problems with it, including size and speed. It's not even okay as a training example, because the HIGH notch is not to sensor specs at 1000 uS (should be 10uS). It also doesn't insure that the trigger pin is LOW before starting the HIGH notch. Basically, while it may work as an example, it's really not correct and you'll have problems when you try to implement it in a larger sketch.

Tim