March 2019
Intermediate to advanced
312 pages
7h 37m
English
To read the ultrasonic sensor value inside an I2C LCD, connect the ultrasonic sensor and I2C LCD to the RPi. From the GitHub repository of Chapter04, you can download the complete program called I2CLCDdm.cpp program. The wiring connections of I2C LCD, ultrasonic sensor, and the RPi is shown in the following figure:

This I2CLCDdm.cpp program is basically a combination of the DistanceMeasurement.cpp and the I2CLCD.cpp programs. In this program, after declaring all the necessary libraries and variables related to the ultrasonic sensor and the I2C LCD below the cout << "Distance: "<<distance << "cm" ...