About:
In this tutorial, we are going to show you how to download libraries for Arduino IDE and then import these libraries to your Arduino code and then run your Arduino code and use libraries through your Surilli Basic M0.
What Are Libraries?Libraries are a collection of code that makes it easy for you to connect to a sensor, display, module, etc. For example, the built-in LiquidCrystal library makes it easy to talk to character LCD displays. Libraries are files written in C or C++ (.c,.cpp) which provide your sketches with extra functionality (e.g. the ability to control an LED matrix, or read an encoder, etc.).
How to Download Libraries?There are hundreds of additional libraries available on the Internet for download. The two websites commonly used to access and download the libraries include GitHub or the Arduino website.
How to Install and Use Libraries?Method 1: Using the Library ManagerTo install a new library into your Arduino IDE you can use the Library Manager.
Open the IDE and click to the "Sketch" menu and then click Include Library > Manage Libraries.
Then the Library Manager will open and you will find a list of libraries that are already installed or ready for installation.
Scroll through the list and click on it, then select the version of the library you want to install. Sometimes only one version of the library is available. If the version selection menu does not appear, don't worry: it is normal.
Finally click on install and wait for the IDE to install the library.
Downloading may take time depending on your connection speed. Once it has finished, an Installed tag should appear next to the Bridge library. You can close the library manager.
You can now find the new library available in the Sketch > Include Library menu.
Importing a .zip Library:Libraries are often distributed as a ZIP file or folder. The name of the folder is the name of the library. Inside the folder will be a .cpp file, a.h file and often a keywords.txt file, examples folder, and other files required by the library.
You can also install 3rd party libraries in the Arduino IDE.
Do not unzip the downloaded library, leave it as is.
In the Arduino IDE, navigate to Sketch > Include Library > Add.ZIP Library. At the top of the drop down list, select the option to "Add.ZIP Library'' and then add the.zip file of the downloaded library.
You will be prompted to select the library you would like to add. Navigate to the.zip file's location and open it.
Return to the Sketch > Include Library menu. You should now see the library at the bottom of the drop-down menu. It is ready to be used in your sketch. The zip file will have been expanded in the libraries folder in your Arduino sketches directory.
NOTE: The Library will be available to use in sketches, but with older IDE versions examples for the library will not be exposed in the File > Examples until after the IDE has restarted.
Method 2: Manual InstallationWhen you want to add a library manually, you need to download it as a ZIP file, expand it and put in the proper directory. The ZIP file contains all you need, including usage examples if the author has provided them.
The library manager is designed to install this ZIP file automatically as explained in the former chapter, but there are cases where you may want to perform the installation process manually and put the library in the libraries folder of your sketchbook by yourself.
You can find or change the location of your sketchbook folder at File > Preferences > Sketchbook location.
Go to the directory where you have downloaded the ZIP file of the library.
Extract the ZIP file with all its folder structure in a temporary folder, then select the main folder, that should have the library name.
Copy it in the “libraries” folder inside your sketchbook.
Start the Arduino Software (IDE), go to Sketch > Include Library. Verify that the library you just added is available in the list.
NOTE: Arduino libraries are managed in three different places: inside the IDE installation folder, inside the core folder and in the libraries folder inside your sketchbook. The way libraries are chosen during compilation is designed to allow the update of libraries present in the distribution. This means that placing a library in the “libraries” folder in your sketchbook overrides the other libraries versions.
The same happens for the libraries present in additional cores installations. It is also important to note that the version of the library you put in your sketchbook may be lower than the one in the distribution or core folders, nevertheless it will be the one used during compilation. When you select a specific core for your board, the libraries present in the core’s folder are used instead of the same libraries present in the IDE distribution folder.
Last, but not least important is the way the Arduino Software (IDE) upgrades itself: all the files in Programs/Arduino (or the folder where you installed the IDE) are deleted and a new folder is created with fresh content.
This is why we recommend that you only install libraries to the sketchbook folder so they are not deleted during the Arduino IDE update process.
STEP 1: Plug In Your Surilli Basic M0 to the PCNote: If you have already gone through the “Getting Started Guide", skip to next step. Else, go through our getting started guide and then return to step 2. This is highly recommended.
STEP 2: Open Arduino IDE and Add Any Library to Arduino CodeFirst, download the library that you need for any project that you are going to develop and move that library folder after unzipping it to PC > Documents > Arduino > Libraries.
Now open Arduino IDE and select the downloaded library from: Sketch > Include libraries. Now select that library that you have just downloaded. After selecting the required library, that library will appear in your Arduino IDE code.
If for example, we have downloaded the "Fade" library and then want to use in our Arduino code, then we will have to follow all the steps as mentioned above.
You will see the Fade.h library included in your IDE as follows.
In this way, any library that you want to use in your Arduino code, can be used by following the same method as mentioned above.
STEP 3: Writing and Uploading Code to Surilli Basic M0Copy and paste any code into your new sketch and then include any library in your code and save it on to your computer.
There are most cases in which an error regarding "Library is not present" prompts up whenever u upload a code which means that the library is not present or you have either not downloaded it or included it.
STEP 4: Upload and Run the SketchCheck that you have selected the right board, processor and port number against your Surilli as follows.
Board = "Surilli Basic M0"
Processor = "ATmega32U4 (3.3V, 8MHz)"
Port = Port number changes on every PC. Select whatever is coming in "Port" tab.
Finally, Upload the sketch on your Surilli Basic M0 using the "Upload" button on your Arduino IDE.
Wait for the the program to be uploaded. After its shows "Done Uploading", you can perform any task with your Surilli Basic M0 based on what code you have uploaded to it.
That’s all. Simple but a good one to start off. If you have any queries, you can always visit our website at surilli.io or contact our support. Thank you. Keep visiting for more.
Comments
Please log in or sign up to comment.