Help in US 100 Ultrasonic Sensor codes

encrypted05:
I used a different code I found from the internet and it worked so the problem is probably in the codes. Unfortunately, the codes that worked, gives a different output to what I prefer and I’m having a hard time modifying it.

By 'different output' you mean m vs inches and cm ? That's easy to fix. Change the multiplier in this line. ``` distance=distance*0.0001657; ``` To output cm, it should be 100x larger. To output inches it should be 2.54x smaller than that (cm) number.

Also what Arduino are you using ?

The library you tried doesn’t use the pulseIn() function. Instead it attempts to setup a timer to do the pulse measurement. The timer names change w/the varying MCUs used. The author appears to have tried to code the library for the 32U4 and 328.