Introduction: Arduino - Install and Use Arduino Libraries
How to install and use Arduino Libraries
Arduino libraries are a convenient way to share code such as device drivers or commonly used utility functions. This guide details how to install libraries on your computer.
Step 1: Types of Arduino Libraries
There are two general types of Arduino Libraries:
a) Standard Libraries
The Arduino IDE comes with a set of standard libraries for commonly used functionality. These libraries support all the examples included with the IDE. Standard library functionality includes basic communication functions and support for some of the most common types of hardware like: Servo Motors and Character LCD displays.
b) User Installed Libraries
There are many other libraries with useful functionality and device drivers for all sorts of hardware. These drivers are available from places like Arduino Playground, Github and Google Code.
!!! User installed libraries should be installed in your sketchbook libraries folder so they can be used with all versions of the IDE. This way, if a new version of the IDE is released, you don't have to re-install all your favorite libraries!
Step 2: Where to Install Your Libraries
It is important to install your libraries in the correct location.
Otherwise the compiler will not be able to locate them when you try to compile and upload your sketches.
Locate your Sketchbook Folder and the Libraries Folder Inside
Your sketchbook folder is the folder where the Arduino IDE stores your sketches. This folder is automatically created by the IDE when you install it.
On Linux machines, the folder is named "Sketchbook" and it is typically located in /home/
On Windows and Macintosh machines, the default name of the folder is "Arduino" and is located in your Documents folder.
!!! This is a common source of confusion on Windows and Mac machines, your sketchbook folder is not named "sketchbook" it is named "Arduino"!
User installed libraries should go in a folder named "Libraries", located inside your sketchbook folder. This is where the IDE will look for user installed libraries.
!!! On version 1.0.2 and later of the Arduino IDE, the "Libraries" folder is created automatically. On earlier versions of the IDE, you may need to create it when you install your first library.
Open the Preferences Click "File->Preferences" in the IDE.
Find the Sketchbook Location Usually a folder named "Arduino" in your Documents folder.
Once you know the location, navigate to this folder in Windows Explorer.
Step 3: Using Libraries
One of the best features of the Arduino project is the ability to add on pre-crafted libraries that add hardware support.
There's tons of them, and you can pick and choose which to install. They're only loaded in when the sketch you're working on needs them, so for the most part you can download and stash them for future use.
Sketches will often depend on libraries, you can see what they are by looking at the top of the sketch. If you see something like:
That means that you'll need a library called AFMotor.h
If you don't have it installed you'll get an error
Step 4: Installing a Library on Windows
a) Close the Arduino IDE
First make sure that all instances of the Arduino IDE are closed. The IDE only scans for libraries at startup. It will not see your new library as long as any instance of the IDE is open!
b) Download the Zip File
c) Uncompress the ZIP file onto your desktop
d) Paste into your Libraries Folder
Step 5: Give It a Legal Name
The IDE will not recognize folders with dashes in the name.
So you must rename the Github Master Folder. Underscores are OK!
Rename the uncompressed folder AFMotor and NewPing
Check that inside AFMotor is AFMotor.cpp and AFMotor.h files.
Step 6: Verify That It Compiles
a) Re-start the IDE
Restart the IDE. You should now have a submenu called File->Examples->AFMotor->MotorParty
b) Verify that it Compiles Click the check-mark icon in the upper left and verify that the example sketch compiles without errors.
Step 7: If It Helps, Please Subscribe
First of all, I would like to thank you for reading this guide ! I hope it helps you.
If you want to support me, you can subscribe my channel and watch my videos.
6 years ago
i have installed the dht.cpp and dht.h files to the arduino library, but still im getting the same error!!
what do i do ?
the error is:
Arduino: 1.6.12 (Windows 10), Board: "Arduino/Genuino Uno"
D:\projects\it-b\mini\3rd yr\naturalis\arduino\CODE\dht11_bluetooth_testcode\dht11_bluetooth_testcode.ino:2:17: fatal error: DHT.h: No such file or directory
exit status 1
Error compiling for board Arduino/Genuino Uno.