The power and convience of the Arduino system is the extensive availability of libraries for almost every sensor and acutator availble. To use a device, one only needs to interface the device to the Arduino system (following the many tutorials available on the Internet), locate the library (code to interact with the device), load the library into the IDE, write and compile your application.
This makes the Arduino a very versatile system which is easy to implement and available to hobbists to expert.
The library consists of
To use the library we need to “load” the library into the Arduino system. There are 3 methods to do this:
First, let us note down the folders where the libaries may be located:
Library | Folder location |
---|---|
Arduino IDE System Libraries | C:\Program Files (x86)\Arduino\libraries |
User libraries | D:\Users<username>\Documents\Arduino\libraries |
You can locate the User library folder by using the IDE > File > Preferences to locate the Sketchbook location where the user library location can be found.
The simplest method of loading a library is to use the Library Management tool in the IDE. This is located using IDE > Tools > Manage Libraries
Type in the name of the library you want to load and click OK. The Arduino IDE will handle the reat. The library and the example file(s) will be automatically downloaded and installed. The library will be automatically installed in the User Library Folder.
This is the simplest way of loading a library. The library may now be included using the IDE > Sketch > Include Library. You will be able to file the new library in the list. clicking on the library will inert the “#include
Problems: Sometimes the library you require is not in the System Library list because the device is new or rarely used, you may have re-written the library or is only available for a particular version of the device.
The second method requires you to
This method of loading the library allows you to select a particular library for your code. Hence, you can include your own libraries or a particular library the works only with your board.
Problems: There are so many libraries out there. You need to know specifially which one you would like to use and once you ahve checked that it is working, put a note in your code where you have obtained your code for future reference.
This is the most manual method of installing a libary where the user have full control. Note however, that this method is not recommended as you can make mistakes or located your files in wrong folders etc. This method requires you to
The library will be displayed and included the normal way as in the above 2 cases. This allows you to even include libraries that you have written yourself.
Problems: Errors may occur that will halt your IDE, which may give rise to other problems in troubleshooting.
Use the following table as a guide to the tested libraries and code for your IO devices : IO Devices Collection
Here is a link to some sample code (incomplete)
Updated January 2021