#include is used to include outside libraries in your sketch. This gives the programmer access to a large group of standard C libraries (groups of pre-made functions), and also libraries written especially for Arduino.
The main reference page for AVR C libraries (AVR is a reference to the Atmel chips on which the Arduino is based) is here.
Note that #include, similar to #define, has no semicolon terminator, and the compiler will yield cryptic error messages if you add one.
- LibraryFile.h: When the angle brackets syntax is used, the Arduino IDE seaches for the LibraryFile.h in the libraries paths.
- LocalFile.h: When the double quotes syntax is used, the Arduino IDE searches for the LocalFile.h in the sketch's folder. If the file is not found, the Arduino IDE will searches for the file in libraries paths.
- : libraries paths includes
- The path that contains the built-in libraries of Arduino IDE. It is located at where Arduino IDE is installed.
- The path that contains the libraries installed via Library Manager of Arduino IDE. In Windows, it usually located at C:\Users\YOUR_ACCOUNT\Documents\Arduino\libraries.
- : sketch's folder is the folder that your sketch (.ino file) is located.
This example includes the Servo library so that its functions may be used to control a Servo motor.
This example includes the pitches.h file, which is placed in the same directory with the sketch (the sketch's folder).