ARDUINO SOFTWARE LIBRARIES

(Get ..almost.. all the Libraries used in our examples HERE:)

And many useful Libraries here from Rob Tillaart!

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.

NEW, Easier way to install Arduino Libraries (Link):


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
  • Ultrasonic_Serial:4: error: 'Ultrasonic' does not name a type
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!

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:
http://arduino-info.wikispaces.com/CombiningArduinoSketches

libraries_folder.jpgFINDING your Arduino "libraries" Folder

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.
ImportLibrary.jpg

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.






Installing New Libraries: The New, Easier way:

AddLibrary.jpgArduino IDE release 1.05 now has a much easier way of adding new libraries. See the photo:
In the Arduino IDE, click Sketch>ImportLibrary>AddLibrary
(Add Library is at the very TOP of the list of currently installed Libraries.) Click on it and you will get a selection window. Navigate to the ZIP file or folder containing the new library and click on it. LibraryAdded.jpgIf the library is installed successfully, you will see this (right) in the lower status bar of the Arduino IDE.

NOTE: The new library is immediately recognized by the IDE, without restarting!

Installing New Libraries: The Old / Basic way:


(Arduino as of 1.05 version has an easier way to install libraries that come in the form of a .ZIP file or folder . See above section!)

CLOSE the Arduino IDE if it's open.. Open it AFTER you install the new library folder INSIDE the "libraries" folder.

Now you're ready to actually get the new library into the "libraries" folder. To do so, download the library you need and unzip it to some temporary folder or desktop. It should be in a folder of its own, and will typically contain at least two files, one with a .h suffix and one with a .cpp suffix.

IF you downloaded the ZIP file from GitHub or some other place it may have a funny folder name like "freetronics-IRTemp-d10478b" when you unzipped it). Rename it so that the SAME name is used for:
  • The Folder
  • The .h file and .cpp file Inside the folder
In the above example, the folder name should be "IRTemp" .

Open your Arduino "libraries" folder. Drag and Drop the new library folder in there. Then re-start the Arduino programming environment, and you should see your new library in the Sketch > Import Library menu.

WHY LIBRARIES?


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.

LibraryExamples.jpgEXAMPLE Sketches:


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 have uploaded a Zip file with the complete "libraries" folder we currently have (and will update from time to time).
You can download it here: 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.

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.



.