You are on page 1of 3

Language Reference

Structure Functions
 void setup() Digital I/O
 void loop()
 pinMode(pin, mode)
Control Structures  digitalWrite(pin, value)
 int digitalRead(pin)
 if
 if...else Analog I/O
 for
 switch case  int analogRead(pin)
 while  analogWrite(pin, value) - PWM
 do... while
 break Advanced I/O
 continue
 return  shiftOut(dataPin, clockPin, bitOrder,
value)
Further Syntax  unsigned long pulseIn(pin, value)

 ; (semicolon) Time
 {} (curly braces)
 // (single line comment)  unsigned long millis()
 /* */ (multi-line comment)  unsigned long micros()
 delay(ms)
Arithmetic Operators  delayMicroseconds(us)

 = (assignment) Math
 + (addition)
 - (subtraction)  min(x, y)
 * (multiplication)  max(x, y)
 / (division)  abs(x)
 % (modulo)  constrain(x, a, b)
 map(value, fromLow, fromHigh,
Comparison Operators toLow, toHigh)
 pow(base, exponent)
 == (equal to)  sq(x)
 != (not equal to)  sqrt(x)
 < (less than)
 > (greater than)
 <= (less than or equal to)
 >= (greater than or equal to)

Boolean Operators
Trigonometry
 && (and)
 || (or)  sin(rad)
 ! (not)  cos(rad)
 tan(rad)
Compound Operators
Random Numbers
 ++ (increment)
 -- (decrement)  randomSeed(seed)
 += (compound addition)  long random(max)
 -= (compound subtraction)  long random(min, max)
 *= (compound multiplication)
 /= (compound division) Communication

 Serial
Variables
Variables are expressions that you can use
in programs to store values, such as a sensor Conversion
reading from an analog pin.
 char()
Data Types
 byte()
 int()
Variables can have various types, which are
described below.  long()
 float()
 boolean
 char
 byte
Constants
 int
 unsigned int Constants are particular values with specific
 long meanings.
 unsigned long
 float  HIGH | LOW
 double  INPUT | OUTPUT
 string  true | false
 array  Integer Constants
 void

You might also like