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