What is a library, anyway?
When you want to attach sensors or other new parts (or ‘hardware’) to your Arduino board, it is often necessary to install a ‘library’ so that the board knows how to communicate with this new hardware. This is very much like when you plug a new printer into your computer: you have to install the required drivers or programs for it to work properly.
The following instructions will guide you through installing the library that will allow you to control an ultrasonic sensor with your Arduino board.
Step 1: Download the NewPing library
You can download the ‘NewPing’ library by clicking the ‘Download NewPing’ button which can be found on any of the project pages which use an ultrasonic sensor. You can also press the button below which will begin downloading a zip file automatically.[button color=”extra-color-1″ hover_text_color_override=”#fff” image=”default-arrow” size=”large” url=”https://bitbucket.org/teckel12/arduino-new-ping/downloads/NewPing_v1.8.zip” text=”Download NewPing” color_override=””]
Step 2: Copy the library into the Arduino software
If you are using ‘Microsoft Edge’ or ‘Internet Explorer’, you may need to confirm that you want to save the zip file to your computer. Otherwise, the file will now be saved in your ‘Downloads’ folder. You now need to copy the file – it should be called something like ‘NewPing_v1.8.zip’ – and paste it into the folder in Documents > Arduino > Libraries.
The following screenshots will show you the process. Note that for this demonstration, we used the Google Chrome browser installed on Microsoft Windows. The process will be relatively similar when using other browsers or the Mac operating system.
Step 3: Add the library in the Arduino software
You now need to tell the Arduino software that a new library called ‘NewPing’ is available. this is done by opening the Arduino software and then selecting Sketch > Include Library > Add ZIP library.
Again, we’ve included screenshots to help along the way.