64 }
65 else {
66 sensorValue = analogRead(sensorPin);
67 if(sensorValue<=10) // the reading is invalid.
68 {
69 Serial.print("Invalid");
70 }
71 else {
72 sensorValue = sensorValue*0.718;
73 Serial.print(sensorValue);
74 Serial.println("cm");
75 }
76 }
77 }
result
Open the IDE serial port, the distance is display on it.