riteshRcH / waterproof_small_blind_ultrasonic_sensor_DYP-A02YYxx_v1.0

**********Software is a rough test code. Feel free to contribute and optimize it. Thanks!**********
0 stars 0 forks source link

I'm grateful for the content, but i have a question. #6

Closed elrdi closed 4 years ago

elrdi commented 4 years ago

First of all, thank you for the content. I have a question about the line 50, in which you wrote the following instruction : distance = distance / 58 ; Where did this 58 come from? I really wanna know. And once more , thank you !

riteshRcH commented 4 years ago

The PulseIn function returns a time in microseconds, and since sound travels at approximately 29cm / microsecond, we can figure out a distance. The distance returned would be the distance the sound traveled (to the object and back), so we will have to also divide the distance by two: returnTime / 29 / 2 (or returnTime / 58 to simplify it)

elrdi commented 4 years ago

thanks !!