ZidongGuo / Desktop-Roomba

0 stars 0 forks source link

Test four ultrasonic sensors #14

Closed ZidongGuo closed 3 years ago

ZidongGuo commented 3 years ago
ZidongGuo commented 3 years ago

Set up the voltage divider

Pick one 1k ohms resistor +one 4.7k ohms resistor as the top half of the voltage divider and one 10k ohms resistor as the bottom half of the voltage divider.

ZidongGuo commented 3 years ago

Connect one HC-SR04 sensor to Raspberry Pi

Connect Vcc from the sensor to the 5v power from the Pi, GND from the sensor to GND from the Pi, Trig from the sensor to GPIO5. Connect the Echo from the sensor in series with one leg of the 1k ohms resistor Run in VNC session

sudo piscope

and then run the python script with

python3 hc-sr04.py

Expected result: Show a correct distance between the object in front of the sensor in the command window and see a right pulse in the piscope

ZidongGuo commented 3 years ago

Modify the Read_Ultrasonic_Distance() into four different functions to monitor distances in four directions (Left Right Front Back)

image