Using HY-SRF05 ultrasonic sensor.

Attached is a schematic for a mock up of a back up sensor with LEDs. Everything works if I move an object away from the sensor, but if I move an object towards the sensor I get “false” reactions i.e. changing from led1 and led2 being on to led1, led2, and led3 being on as the object gets closer to sensor which is opposite of what the code states.

Any reason this would happen?

Also, I used to conversion of pulse duration to cm from another sketch, however the distances do not work out correctly. Can the sensor be calibrated or do I calculate a difference factor?

srf_2.ino (1.45 KB)