- 1 ARDUINO SOFTWARE LIBRARIES
- 2 Which Libraries do I have Installed??
ARDUINO SOFTWARE LIBRARIES
Many great additional capabilities to run new and different hardware devices are available in Libraries whose code was written and contributed by many different people. Example: The OneWire and DallasTemperature libraries are needed to easily use the DS18B20 temperature sensors.
NOTE! If you get a Library that is labelled "Master", like "RF24-Master.zip" you must RENAME the Zip file AND the folder inside it to remove the "-Master" part! Otherwise the new "Easy Install" will fail with "Library Name not allowed" etc. (This is because these libraries came from GitHub). Details!
Arduino Libraries contributed by users:
There are many (hundreds) of very useful libraries contributed by people in the Arduino Community. Most of these libraries are now listed on the Arduino.cc site. Click on The main ARDUINO LIBRARY LIST to see them. The following is an outline of the available categories:
- Data Structures and Algorithms
- Graphing Data
- Home Automation and Internet of Things
- Input / Output
- Buttons & Debouncing
- LED Control
- Multiple LED Control
- Other Input / Output
- Textual LCDs
- Graphical/Color LCDs
- Motion Control
- Motor Drivers
- Power Control
- AC Zero-Cross PWM
- Signal Processing
- Schedulers and Pseudo Operating Systems
- Storage & Memory
- Testing, Utilities and Power Saving
Get many useful Libraries here from Rob Tillaart!
ERRORS you may see caused by Library problems:
When you try to Verify (Compile) an Arduino sketch you may see error messages like these:
- Ultrasonic_Serial.pde:1:24: error: Ultrasonic.h: No such file or directory </span>
- Ultrasonic_Serial:4: error: 'Ultrasonic' does not name a type</span>
If you are seeing errors like those, it means a Library the sketch needs cannot be found. This is probably because you never downloaded the needed library, or it was installed incorrectly. Here, we'll try to explain this Library Stuff!</span>
SKETCHES and LIBRARIES: What's the difference??
Sketchbook projects ("Sketches") and Libraries are two different things.
Libraries are software tools that other people wrote that you can use in your various Arduino projects.
Sketches are saved in *.ino files which are your Arduino applications that you create. They have the setup() and loop() routines, which are the high level portions of code that drive your software. Arduino "Sketches" are what other systems call "Programs"...
Your *.ino files can be in the sketchbook location (for easy access) or anywhere else you want to put them. Just open them and use them. Your .ino sketches have access to the library tools even if the .ino is not in the sketchbook.
NOTE: The newer Arduino IDE 1.0x versions of the IDE save Sketches as ".ino" files. Older versions like 0023 save sketches as .pde files. The IDE will not display sketches that have the 'other' filetype, but you CAN load them by going to File>Load and navigating to them. When you save them they will be saved with the filetype of .pde (IF you are running the 0022, 0023 IDE) or .ino (IF you are running the 1.0x IDE).
Later: Combining Arduino Sketches
This is often difficult. Here is an approach that may help you be successful:
This is sometimes confusing. Here's the easy way to find yours:
- Start your Arduino IDE Software
- Click on FILE and then PREFERENCES
- See the SketchBook Location entry, and copy it.
- Paste that location into Windows Explorer or MAC Finder
- Find the folder there named "libraries". IF it does not exist, create it.
- Make a desktop shortcut to that folder (rightclick and drag it to the desktop). Later you can use this to easily check out your "libraries" folder. This is also the target folder you will drag and drop new Library folders into.
Which Libraries do I have Installed??
You can check on which libraries have been installed in your Arduino IDE:
Click on Sketch and hover over Import Library. You will see a list like this (right) of the libraries you have installed. NOTE: The Libraries at the top, before the horizontal bar are Libraries that come pre-installed with every Arduino IDE. Below that are "Contributed" libraries that you have installed.
Libraries provide extra functionality for use in sketches, e.g. working with hardware or manipulating data. To use a library in a sketch, select it from the Sketch > Import Library menu. This will insert one or more #include statements at the top of the sketch and compile the library with your sketch. Because libraries are uploaded to the board with your sketch, they increase the amount of space it takes up. If a sketch no longer needs a library, simply delete its #include statements from the top of your code.
There is a list of libraries, here in the Arduino Reference. Some libraries are included with the Arduino software. Others can be downloaded from a variety of sources.
Arduino now has a Library Manager that makes it much easier to install libraries.
Most libraries come with example sketches to show how to use them. Get to them from the Examples menu item (right). The first section comes with every Arduino installation, followed by libraries you have added, followed by standard libraries supplied with Arduino.
If you use an example, SaveAs with a new name if you want to be able to change it.
ArduinoInfo.Info Example Software: Current Library Contents
Even after using and installing libraries for a while, it is still sometimes challenging to get everything to work. Many libraries have finally been upgraded to work OK with Arduino IDE1.0 and later as well as earlier versions. There are many example software sketches on this ArduinoInfo.Info WIKI and many use libraries. We will provide a zip file with most of those libraries later (UNDER CONSTRUCTION!)
You then could Unzip it into your arduino sketchbook > libraries folder, or unzip it in a temporary location and copy the libraries you want into your "libraries" folder. NOTES: Look at the #include statement(s) in your sketch. The filename should change color to "red-orange" from black. That means the library was found. (You should see a "keywords.txt" file in the library folder. You can check for that. A few libraries do not implement this and the color will not change).
CUSTOM SKETCHBOOK/LIBRARY LOCATION:
A SUGGESTED WAY IF YOU WANT TO CREATE A CUSTOM SKETCHBOOK/LIBRARY LOCATION:
If you want to add a new library to the library system, so that it may be used by a program in an "include" statement, then put it in the libraries folder inside your Sketchbook Folder..
Decide where you want your own sketches to be, create that folder, put your sketches there. Go to: File, Preferences, and set the sketchbook location to that location. If there is NOT yet a "libraries" folder then create it. Put folders with libraries you download or create in the "libraries" folder.</span>
The IDE (Interactive Development Environment) wants each sketch to be in its own folder, so they have should be in a folder of the name of the .ino file in the sketch folder. Then they will appear in your sketches menu. The easiest way to do this is to open your file, and go to File / Save As, and browse to that sketchbook location and save the file to that folder. The IDE will automatically detect that you are in the sketchbook, and create a subfolder of the same name.