The HC-SRO4 sensor consists of four pins: VCC, GND, trigger (Trig), and echo, so the wiring connections of the RPi and the ultrasonic sensor should be as follows:
- Connect the VCC pin of the sensor to pin number 4.
- Connect the GND pin of the sensor to pin number 9.
- Connect the Trig pin of the sensor to wiringPi pin number 12.
- The echo pin of the sensor is connected to wiringPi pin number 13 via a voltage divider. The two resistors used in the voltage divider circuit have a resistance value of 1 KΩ (R1) and 2KΩ (R2), respectively. The voltage divider circuit is used to reduce the incoming 5V signal from the echo pin (to the RPi) to 3.3V. The wiring connection of RPi and HC-SR04 is shown in the ...