Catalog / Arduino Cheatsheet
Arduino Cheatsheet
A quick reference guide for Arduino development, covering essential concepts, code snippets, and hardware information for both beginners and advanced users.
Arduino Fundamentals
Basic Structure
Every Arduino program (sketch) has two essential functions:
|
Example:
|
Data Types
|
Integer (whole number). Typically 2 bytes (-32,768 to 32,767). |
|
Unsigned integer (0 to 255). |
|
Long integer. Typically 4 bytes (-2,147,483,648 to 2,147,483,647). |
|
Floating-point number (number with decimal point). 4 bytes. |
|
Boolean value (true or false). |
|
Character. 1 byte. |
Digital I/O
|
Sets the specified pin as |
|
Writes |
|
Reads the value ( |
Analog I/O & Serial Communication
Analog I/O
|
Reads the value from the specified analog pin (0 to 1023). |
|
Writes an analog value (PWM signal) to a pin (0 to 255). Only works on PWM enabled pins (marked with ~ on the board). |
|
Configures the reference voltage used for analog input ( |
Serial Communication
|
Initializes serial communication at the specified baud rate (e.g., 9600, 115200). |
|
Sends data to the serial port as human-readable ASCII text. |
|
Sends data to the serial port, followed by a carriage return and line feed. |
|
Gets the number of bytes (characters) available for reading from the serial port. |
|
Reads the first available byte of incoming serial data. |
Time Functions
|
Pauses the program for the amount of time (in milliseconds) specified as parameter. |
|
Returns the number of milliseconds since the Arduino board began running the current program. This number will overflow (go back to zero) after approximately 50 days. |
|
Returns the number of microseconds since the Arduino board began running the current program. This number will overflow (go back to zero) after approximately 70 minutes. |
Control Structures & Operators
Control Structures
|
|
|
|
|
|
Operators
|
Assignment operator (assigns a value to a variable). |
|
Equality operator (checks if two values are equal). |
|
Inequality operator (checks if two values are not equal). |
|
Greater than operator. |
|
Less than operator. |
|
Logical AND operator (returns true if both conditions are true). |
|
Logical OR operator (returns true if at least one condition is true). |
|
Logical NOT operator (reverses the logical state of its operand). |
Math Operators
|
Addition. |
|
Subtraction. |
|
Multiplication. |
|
Division. |
|
Modulo (returns the remainder of a division). |
Advanced Arduino
Interrupts
|
Attaches an interrupt to the specified pin. |
|
Detaches the interrupt on the specified pin. |
|
Re-enables interrupts (after they have been disabled by |
|
Disables interrupts. |
Libraries
Libraries provide extra functionality to your sketches. To include a library:
Examples:
|
EEPROM
|
Writes a byte to the EEPROM at the specified address. |
|
Reads a byte from the EEPROM at the specified address. |
|
Writes a byte to the EEPROM at the specified address, only if the new value is different from the old value. |