I have a Parallax Ping sensor and I can't get the example sketch for it to work properly. The sensor is being activated but the duration value returned by pulseIn is far too big. If I put millis() calls either side of the pulseIn() call the delay between them is about 9 milliseconds, but the duration value returned is 35568633, so the distances calculated are similarly massive. For example:
start = 3334 end = 3343 dur =35693633 ,241173in, 615407cm start = 3501 end = 3510 dur =35693633 ,241173in, 615407cm start = 3668 end = 3678 dur =35381133 ,239061in, 610019cm start = 3836 end = 3846 dur =35381133 ,239061in, 610019cm start = 4004 end = 4014 dur =35318633 ,238639in, 608941cm start = 4172 end = 4182 dur =35318633 ,238639in, 608941cm start = 4340 end = 4349 dur =35631133 ,240750in, 614329cm
My only modification to the example is adding the two millis() calls:
start = millis(); duration = pulseIn(pingPin, HIGH); end = millis();
The value I get back does get (a little) smaller as I move my hand toward the sensor. I tried a sketch at liquidware which yabb won't let me link to right now, and it too shows the value going down as I move my hand closer, so the sensor seems to be working.
I am trying this on a Diecimila from Ubuntu Intrepid with avr-gcc 4.3.0. I get the same duration value back with arduino-011, 012 and 013.