In this project, I connect an HC-SR04 ultrasonic sensor to a Raspberry Pi. I share python code for calculating the distance to an object in front of the sensor. I show how to use a voltage divider for the 5V model of the sensor. Also includes a comparison of results from 4 different models.
This project was inspired by Lessons 21-23 in Paul McWhorter's Raspberry class: [ Ссылка ]
Project Code on Github
Basic Program for Distance in cm and inches:
[ Ссылка ]
Program to store readings in a file (data.txt):
[ Ссылка ]
Song: Atch - This Feeling
Music provided by Vlog No Copyright Music.
Creative Commons - Attribution 3.0 Unported
Video Link: [ Ссылка ]
#raspberrypi #python #ultrasonicsensor
![](https://s2.save4k.ru/pic/C02oB1n7rcg/maxresdefault.jpg)