Hi teoxan, thanks for the reply.

I'm aware there are two operating modes for the SRF05. I'm using the single pin mode. However, dividing by 58 does not give results in cm.

Anything below 10cm, I get a 6 digit number. So for 5cm, I get a result of 500000. Above that (i.e. above 10cm), I get a 7 digit number. E.g., 20cm gives 2000000. Up until 100cm, if I removed the last 5 digits, I would get an approximate answer in cm. Above 100cm I still get a 7 digit number, and removing the last 4 digits would give me an approximate result in cm. It seems the result is truncated after 7 digits...

I'm not sure if the result is getting truncated or what (it's an unsigned long... so it shouldn't, I don't think). But I can't just cut off a constant number of digits, as >10cm and >100cm both give a 7 digit number.

Any ideas why this is? At the moment I'm using an unsigned long for the pulse duration, and for the distance. When displaying this result to the LCD, I'm using ltoa(), which presumably could be the cause of errors except for the fact that even outputting the raw values to serial gives the same results...

I'm a bit stumped here. I'm sure it's something obvious that I'm missing. But there is no way that dividing by 58 gives a cm result.

Suggestions?

Regards,

Thom