Digging deep into Arduino libraries
We had discussed functions in the The working section of Chapter 6, Safety Box. If you would have thought that we will need to write our own function for getting the distance using our sensor, you would have been right, if it wasn't for, drum roll please....
Libraries!!
An Arduino library is a file that is a package of functions and declarations for other programs to use. Since we need to use the ultrasonic proximity sensor, instead of implementing the math ourselves, and writing our own functions, we can use the <Ultrasonic Distance Library>
, which has the functions required to calculate and work with the distance sensor.
Downloading and installing an Arduino Library
To download and install the Arduino library, you must follow the following instructions:
For this project, you may download the library from:
To install the library, put the
NewPing
folder inlibraries
.In the Arduino IDE, create a new sketch (or...