Raspberry Pi GPIO Programming with Python - Part 5: HC-SR04 Ultrasonic Distance Sensor

preview_player
Показать описание
This is the fifth video of the Raspberry Pi GPIO Programming with Python Tutorial. In this video, we'll see how to use the HC-SR04 ultrasonic distance sensor with the Raspberry Pi to measure the proximity of objects to the ultrasonic sensor.
We'll see the circuit setup and then give two examples in Python. Both of them will be showing the distance to the object and the second example will include a buzzer in order to create a kind of parking sensor effect.

For detailed information about gpiozero interface you can go and check the website (the first piece of code is directly taken from the gpiozero documentation):
Рекомендации по теме
Комментарии
Автор

Super effective video, thanks and congratulations for the job well done. I even just logged in to comment on that regard :)
By the way, you can use a neat little trick called string interpolation to reduce typing without loosing readability, for example:

print(f'Distance to sensor is {sensor.distance} m')

Note the f before the quote and the curly brackets to enclose the

adolfomotanavarro
Автор

Hello! When I ran the program, it will only show an accurate measurement at the first reading. But when I tried moving the obstacle, the reading remains the same regardless of where I put the obstacle. Do you have an idea on how to fix this problem? Thanks.

kurtroyales
Автор

Can i add 2 more sensor in the same raspberry? volts problems?

siriustoolshobbies
Автор

What to do if it constantly shows only 100

ABHi-oesy
join shbcf.ru