Language Reference
Arduino programs can be divided in three main parts: structure, values (variables and constants),
and functions.
Structure
Variables
Functions
Constants
Digital I/O
setup()
loop()
HIGH | LOW
pinMode()
Control Structures
INPUT | OUTPUT|
INPUT_PULLUP
digitalWrite()
digitalRead()
true | false
if
if...else
for
switch case
while
do... while
void
break
boolean
analogReadResolution()
continue
char
analogWriteResolution()
return
unsigned char
goto
byte
tone()
int
noTone()
Further Syntax
Analog I/O
integer constants
floating point
constants
Data Types
analogReference()
analogRead()
analogWrite() - PWM
Due only
Advanced I/O
; (semicolon)
unsigned int
shiftOut()
{} (curly braces)
word
shiftIn()
// (single line
comment)
long
/* */ (multi-line
comment)
unsigned long
short
millis()
float
micros()
double
delay()
string - char array
delayMicroseconds()
String - object
array
min()
Conversion
max()
#define
#include
Arithmetic Operators
= (assignment
operator)
pulseIn()
Time
Math
+ (addition)
- (subtraction)
* (multiplication)
char()
abs()
/ (division)
byte()
constrain()
% (modulo)
int()
map()
word()
pow()
sqrt()
Comparison Operators
== (equal to)
long()
!= (not equal to)
float()
< (less than)
> (greater than)
<= (less than or
equal to)
>= (greater than or
equal to)
Boolean Operators
Variable Scope &
Qualifiers
variable scope
static
volatile
const
Trigonometry
sin()
cos()
tan()
Random Numbers
randomSeed()
random()
&& (and)
|| (or)
! (not)
Utilities
Bits and Bytes
sizeof()
Pointer Access Operators
* dereference
operator
& reference operator
Bitwise Operators
& (bitwise and)
| (bitwise or)
^ (bitwise xor)
lowByte()
highByte()
bitRead()
bitWrite()
bitSet()
bitClear()
bit()
External Interrupts
~ (bitwise not)
attachInterrupt()
detachInterrupt()
Interrupts
<< (bitshift left)
>> (bitshift right)
interrupts()
noInterrupts()
Compound Operators
Communication
++ (increment)
-- (decrement)
+= (compound
addition)
-= (compound
subtraction)
*= (compound
multiplication)
Serial
Stream
USB (Leonardo and Due only)
Keyboard
Mouse
/= (compound
division)
&= (compound
bitwise and)
|= (compound
bitwise or)