After downloading the library created by cnobile the code runs, but only prints 0:
MS: 0, CM: 0.00, IN: 0.00
@edit
I noticied that when I disconnect and connect again the echo pin in runtime sometimes it returns a value (but a very high value), but I tried to change the echo cable and the same problem continues
mzbas:
the solution to the sensor being stuck at zero is in this link. its the 2. post, by docdoc. You will need the NewPing library which is far better.
A working code:
...................................../quote] @mzbas, how about posting your code between code tags in future?
I've just seen two posts by you in a row in which you posted this code inline without code tags.
Not good.
Did you happen to notice that everyone else in this thread took the trouble to do it properly?