AVR libraries in Arduino – Introduction


AVR libraries are developed by Atmel. You might be knowing that the microcontrollers used in most Arduino boards are Atmel microcontrollers (ATmega328P, ATmega2560, etc.). AVR libraries for several specific operations (sleep, time, etc.) already exist, and therefore, we may greatly benefit if we are able to import AVR libraries within Arduino. The good news is that we can!

As per Arduino's website,

"AVR libraries have the potential to greatly extend the Arduino language. The Arduino system is based on the avr-gcc compiler and makes use of the standard AVR libc libraries, which are open-source C libraries, specifically written for Atmel hardware, the maker of the chips upon which the Arduino runs."

The list of AVR libraries can be found on the main AVR library page.

Example

In order to verify that the AVR libraries work within the Arduino IDE, you can simply compile the following code −

#include <avr/sleep.h>
void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println();
}
void loop() {
   // put your main code here, to run repeatedly:
}

You will notice that it compiles without any error, confirming that the AVR libraries get included without any error in Arduino IDE.

Updated on: 24-Jul-2021

618 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements