Skip to Content
Hands-On Robotics Programming with C++
book

Hands-On Robotics Programming with C++

by Dinesh Tavasalkar
March 2019
Intermediate to advanced
312 pages
7h 37m
English
Packt Publishing
Content preview from Hands-On Robotics Programming with C++

Wiring the ultrasonic sensor to the Raspberry Pi

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn Robotics Programming

Learn Robotics Programming

Danny Staple
C++ Reactive Programming

C++ Reactive Programming

Praseed Pai, Peter Abraham

Publisher Resources

ISBN: 9781789139006Supplemental Content