Best of both worlds
Now comes the part where we combine what we have learnt so far in this chapter into one project. We are going use the sensor to calculate the distance between an object and relay this information to be displayed on the LCD screen in real time.
You are going to combine both the circuits from the previous two sections and create something like this:
Note that, at the bottom of the setup, you can see two power VCC/5V/red wires merging into one. We did not use a breadboard because we wanted to save space. A simple way to go about this is to use a male splitter. A crude way is to cut a male to male in two and cut one female to female wire in two, strip off a bit of their plastic insulation and twist the copper ends (two males and one female) together and simply tape the joint.
Open up a new sketch and load the Digital_Ruler.ino
file.
Save it as Digital_Ruler.ino
in your Chapter 2
directory and upload the code to the Arduino.
The result, if everything has gone right, will be exactly...