#include
Description
#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.
Syntax
#include <LibraryFile.h>
#include "LocalFile.h"
Parameter Values
- LibraryFile.h: When the angle brackets syntax is used, the Arduino IDE seaches for the LibraryFile.h in the libraries paths[1].
- LocalFile.h: When the double quotes syntax is used, the Arduino IDE searches for the LocalFile.h in the sketch's folder[2]. If the file is not found, the Arduino IDE will searches for the file in libraries paths.
Where:
- [1]: 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.
- [2]: sketch's folder[2] is the folder that your sketch (.ino file) is located.
Example Code
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).
See Also
- Language : /* */ (block comment)
- Language : {} (curly braces)
- Language : #define (define)
- Language : ; (semicolon)
- Language : // (single line comment)
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |