REFERENCE


This is a curated reference list to the main parts of the Arduino programming language. While the full reference list can be found here, I shortened the list to those components that I find most important to controller design for beginners to understand. This is a great resource for when you read example code and do not understand the function of certain parts.

BASIC FUNCTIONS

pinMode() – Used to set pins as input or output.

digitalRead() – Reads the value of a digital pin, then returns HIGH or LOW.

analogRead() – Reads the value of an analog pin, then returns a value between 0 and 1023. This corresponds with the voltage reading between 0 and max voltage (3.3v or 5v).

delay() – Causes the program to pause for the given time in milliseconds (1/1,000 of a second).

KEYBOARD FUNCTIONS

Keyboard.write() – Emulates pressing a key by sending a keystroke to the connected device.

Keyboard.press() – Emulates pressing and holding a key down.

Keyboard.release() – Emulates releasing a key.

ASCII Table – A list of decimal values for ASCII characters.

Keyboard Modifiers – A list of decimal values for special modifier keys.

MOUSE FUNCTIONS

Mouse.move() – Moves the mouse cursor relative to its current position.

Mouse.click() – Emulates a single mouse left click. This can also be modified to send right and middle clicks.

Mouse.press() – Emulates pressing and holding the left click.

Mouse.release() – Emulates releasing the mouse click.

VARIABLES

bool – Variable type that stores either TRUE or FALSE. Useful for comparisons.

char – Variable type that stores a single character such as ‘a’ or ‘z’. Useful for assigning keystrokes to buttons.

int – Variable type that stores whole numbers.

float – Variable type that can store numbers with decimal points.

void – Void is a keyword used to declare functions.

SKETCH

setup() – The first function that runs when the Arduino turns on. Used to initialize variables, pin modes, and libraries.

loop() – The loop function is the main function that repeats continuously after the setup function and will run indefinitely while the Arduino is powered on.

FURTHER SYNTAX

#define – Used to assign a name to a constant value.

#include – Used to include external libraries in the program.

// (comment) – Used to write comments within the program. Starting a line with “//” will cause the Arduino to ignore any text written on that line.

; (semicolon) – Used to end a statement. Similar to using a period at the end of a sentence.

CONTROL STRUCTURE

If – Checks a condition then executes if that statement is TRUE or skips if that statement is FALSE.

else – Provides greater controller over an “if” statement. When an “if” condition is FALSE, the program will move on to the subsequent “else if” and “else” statements.

for – Repeats the loop for a defined number of iterations.

while – Loops continuously as long as the provided statement is true.

 

ARITHMETIC OPERATORS

= (assignment operator) – Used to assign a value or expression to a variable.

* (multiplication) – Used to multiply.

+ (addition) – Used to add.

- (subtraction) – Used to subtract.

/ (division) –  Used to divide.


COMPARISON OPERATORS

== (equal to) – Used to compare one variable or value to another. Returns TRUE if equal.

!= (not equal to) – Used to compare one variable or value to another. Returns TRUE if not equal.

>  (greater than) – Used to compare if one variable or value is greater than the other.

< (less than) – Used to compare if one variable or value is less than the other.

>= (greater than or equal to) – Used to compare if one variable or value is greater than or equal to the other.

<= (less than or equal to) – Used to compare if one variable or value is less than or equal to the other.

BOOLEAN OPERATORS

! (logical not) – TRUE if the operand is FALSE and FALSE when the operand is TRUE.

&& (logical and) – TRUE only if both operands are TRUE.

|| (logical or) – TRUE if either or both operands are TRUE.