Component
VCC
TRIG
ECHO
GND
Code Overview, Compile and run
The distance sensor code is very straight forward.
We will measure the pulse and how long it takes it to come back so we will know the distance from the sensor to the
object in front of it.
We will print the distance in cm but later on you can change it to any unit you feel comfortable with.
Compile the script by going into the samples directory and running: python3 distance.py
Raspberry Pi
5V
GPIO23
GPIO24
GND
59 of 114
Need help?
Do you have a question about the Raspberry Pi & Arduino Starter Kit and is the answer not in the manual?