You are on page 1of 4

Language Reference

Energia programs can be divided in three main parts: structure, values (variables and constants),
and functions.

Structure
setup()
loop()
Control

Variables

Functions

Constants

Digital I/O

HIGH | LOW

pinMode()

INPUT | OUTPUT

digitalWrite()

INPUT_PULLUP |

digitalRead()

Structures

if

INPUT_PULLDOWN
Analog I/O

if...else

true | false
analogReference()

for

integer constants
analogRead()

switch case

floating point constants


analogWrite()

while

D a t a Ty p e s

- PWM

do... while

void

break

boolean

tone()

continue

char

noTone()

return

unsigned char

shiftOut()

goto

byte

shiftIn()

int

pulseIn()

Fu r t h e r S y n t a x

Advanced I/O

; (semicolon)

unsigned int

{} (curly braces)

word

millis()

// (single line

long

micros()

unsigned long

delay()

float

delayMicrosecond

Time

comment)
/* */ (multi-line
comment)

s()
#define

double

#include

string - char array

Math

min()
Arithmetic
Operators

= (assignment
operator)
+ (addition)
- (subtraction)
* (multiplication)
/ (division)
% (modulo)
Comparison
Operators

== (equal to)
!= (not equal to)

String - object
max()
array
abs()
Conversion

constrain()
char()
map()
byte()
pow()
int()
sqrt()
word()
Tr i g o n o m e t r y

long()
sin()
float()
cos()
Va r i a b l e S c o p e & Q u a l i fi e r s

tan()
variable scope
Random Numbers

static
randomSeed()

< (less than)

volatile

> (greater than)

const

<= (less than or

Utilities

random()
Bits and Bytes

lowByte()

equal to)
sizeof()

highByte()

>= (greater than


or equal to)

bitRead()

Boolean

bitWrite()

Operators

&& (and)
|| (or)
! (not)
Pointer Access
Operators

* dereference
operator
& reference
operator
Bitwise Operators

& (bitwise and)


| (bitwise or)
^ (bitwise xor)
~ (bitwise not)

bitSet()
bitClear()
bit()
External
Interrupts

attachInterrupt()
detachInterrupt()
Interrupts

interrupts()
noInterrupts()
Communication

Serial
Stream

<< (bitshift left)


>> (bitshift right)
Compound
Operators

++ (increment)
-- (decrement)
+= (compound
addition)
-= (compound
subtraction)
*= (compound
multiplication)
/= (compound
division)
&= (compound
bitwise and)
|= (compound
bitwise or)

You might also like