To convert the results to millimeters, just multiply the centimeter results by 10.
multiplying adds 0 at the end nothing more...
You want it to print mm instead of cm in the console?
If so change the abbreviations in the sketch:
Serial.println("cm");
to
Serial.println("mm");
And do as john21403 says to mathematically convert cm to mm.
that changes only printed text ..
but i need real measured values in mm not cm
because cm result is rounded to full cm, but i need to see fraction
and i cant find where the rounding process is in code..
Just use the ping() method instead of ping_cm() then do your own conversion from distance at the speed of sound to mm. Without your sketch it's hard to tell you exactly what to do. But, it would be something like this:
#include <NewPing.h>
NewPing sonar(12, 11, 200); // NewPing setup of pins and maximum distance.
void setup() {
Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
}
void loop() {
delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
Serial.print("Ping: ");
Serial.print(sonar.ping()/6); // Send ping, get distance in mm and print result (0 = outside set distance range)
Serial.println("mm");
}
Keep in mind, I'm dividing by 6 although 5.7 to 5.9 may yield more accurate distances, with the disadvantage of much larger and slower code to do floating point math. So, you could do something like "sonar.ping()/5.7" if you'd like, but your code will be much larger.
Also, keep in mind that the sensor is not accurate down to a mm level, which is why people typically round to the cm level. It can give very stable results at a cm level. However, using the above sketch will give wildly different results each time with no consistency or even more accuracy. Which is why others have just suggested that you multiply by 10 if you really just want to get a value in mm. As it's no more accurate to use the above sketch, and if anything more confusing as the results are always different.
Tim