The standard libraries in Arduino are pre-installed and can be included in the code by simply using the header file of “#include< >”. The standard libraries contain the set of functions that are used to perform basic tasks like communicating with LCDs and dealing with servos motors.
The standard libraries list in Arduino contains a number of libraries, in this write-up, we will discuss and explain all these libraries with some practical examples of using them.
What are the standard libraries of Arduino
Arduino IDE contains a list of standard libraries which are already present in the default folder of “Libraries”, and to use them like other programming languages we have to include the library at the start of the code. The important libraries of Arduino are described as:
LiquidCrystal: The LCD(liquid crystal display) is used for display purposes, it uses the liquid medium in its construction, and its displays use the blocking light principle. The library of LiquidCrystal in Arduino is used to communicate with the LCD and it works either in 4 bit or 8 bits. This library contains a variety of functions, some of them are:
Functions | Description |
---|---|
LiquidCrystal() | This is used to initialize the variable of LiquidCrystal |
setCursor() | This is used to set the position of the cursor on the LCD |
blink() | This is used to blink the cursor and the text on the LCD |
autoscroll() | This is used to turn on the automatic scrolling of the LCD |
begin() | This is used to set the speed of serial communication by using a baud rate |
The library can be included in the code using:
WiFi: WiFi is a revolutionary technology through which we can connect to devices without the use of wires. In Arduino, the WiFi module is present which is responsible for the WiFi communication but to utilize it we have to include the WiFI library in Arduino helps the board of Arduino either to behave as a server, so other devices can connect to it, or as a client, so it can connect to the server. The WiFi library of Arduino supports only WPA2 and WEP encryption but does not support the WPA2 enterprises. The SPI helps the board to communicate with the WiFi which is on pins 11,12,13 on Arduino Uno and 50,51,52 on Arduino Mega. The important functions of this library are:
Functions | Description |
---|---|
ConnectNoEncryption() | This is used to establish a connection with an open network |
ScanNetworks() | This is used to discover the wifi networks from the surroundings which are in the range |
WiFiWebClient() | This is used to establish a connection with a remote network |
connect() | This is used to connect with IP address specified in the arguments |
The library can be included in the code using:
EEPROM: The EEPROM(electrically erasable programmable read-only memory) in Arduino is available only on those boards which have a microcontroller and a Genuino AVR on them. The EEPROM is used to save the data on the board so if the board is disconnected or turned off the data is kept on the board secured. The library of EEPROM helps to read and write the data which is stored on the EEPROM memory. The sizes of EEPROM vary in different boards of Arduino, some have 1024 bytes and some have 512 bytes too. The important functions of this library are:
Functions | Description |
---|---|
read() | This function is used to read the bytes from the EEPROM |
write() | This function is used to write the bytes on the EEPROM |
update() | This function is used to write the bytes on the EEPROM only if it differs from the previous bytes |
get() | This function is used to read and write bytes of any data type on EEPROM |
This library of “EEPROM” can be included in Arduino code using:
Servo: The motors which work on the servo principle, that is the angle of the rotation of the shaft of the motor are controlled by the input voltage are known as a servo. In Arduino, this library is used to control a variety of servos using an Arduino board and even only one timer can control more than two servos. The important functions of Arduino are:
Functions | Description |
---|---|
attach() | This is used to attach the servo to a pin of Arduino |
write() | This is used to write the input value to the servo according to which the rotation is controlled by Arduino |
read() | This is used to read the value of angles according to which the shaft of the servo is rotating |
detach() | This is used to detach the servo from the pin of the Arduino |
The servo library of Arduino can be included in the code using:
SoftwareSerial Library: Serial communication is a method in which data is continuously transferred from one device to another by reading and writing every byte of the data. The SoftwareSerial library is for serial communication using the other pins of the Arduino board (pin 0 and pin 1 are built-in pins for serial communication). The important functions of this library are:
Functions | Description |
---|---|
available() | This function is used to get the number of bytes that can be read for the serial communication |
begin() | This is used to initialize the serial communication at a specific bps (baud per second) speed |
print() | This is used to print the bytes through the serial communication on the serial monitor and serial plotter |
overflow() | This is used for the testing purpose that the serial buffer has been overflowed or not |
This library can be included in the code using:
The other libraries which are included in the standard libraries are:
Library | Description | Header file denotation |
---|---|---|
Ethernet | This includes the functions which help Arduino to connect with the internet | #include <SPI.h>
#include <Ethernet.h> |
Firmata | This includes the functions which help in communicating with the application through serial communication | #include <Firmata.h> |
GSM | This includes the functions which help in the establishment of connections with GSM and GPRS modules | #include <GSM.h> |
SD | This includes the functions which are used to read and write the SD card | #include <SPI.h>
#include <SD.h> |
SPI | This includes the functions which help in communicating with other devices using the SPI(serial peripheral interface) bus | #include <SPI.h> |
Stepper | This includes the functions which are used to control the motion of stepper motors | #include <Stepper.h> |
TFT | This includes the functions which help to use to TFT screen | #include <SPI.h>
#include <TFT.h> |
Wire | This includes the function which is used to send and receive data using the Two-Wire interface | #include <Wire.h> |
Conclusion
The standard libraries already come with the installation files of Arduino IDE and can be used in projects by including their header files at the start of the code. These libraries contain different functions which help us in different tasks. For example, the print() function in the SoftwareSerial library helps to display the output on the serial monitor. In this write-up, we have discussed the standard libraries in detail with an explanation of some important libraries and their functions.