Core language functions, arduino-cli and IDE shortcuts, and wiring basics with a non-blocking timing pattern.
| Category | Function | Description |
|---|---|---|
| Digital I/O | pinMode(pin, mode) | Configures a pin as INPUT, OUTPUT, or INPUT_PULLUP. |
| Digital I/O | digitalWrite(pin, value) | Sets a digital pin HIGH or LOW. |
| Digital I/O | digitalRead(pin) | Reads HIGH or LOW from a digital pin. |
| Analog I/O | analogRead(pin) | Reads a 0-1023 value from an analog input pin (10-bit ADC on most boards). |
| Analog I/O | analogWrite(pin, value) | Writes a PWM (0-255) value to a supported pin — not a true analog voltage. |
| Timing | delay(ms) | Blocks execution for the given number of milliseconds. |
| Timing | delayMicroseconds(us) | Blocks execution for the given number of microseconds. |
| Timing | millis() | Returns milliseconds since the board started — the standard non-blocking-timing building block. |
| Timing | micros() | Returns microseconds since the board started. |
| Serial | Serial.begin(baud) | Opens serial communication at the given baud rate (commonly 9600 or 115200). |
| Serial | Serial.print() / println() | Writes text/values to the serial monitor, with or without a trailing newline. |
| Serial | Serial.available() | Returns the number of bytes waiting to be read from the serial buffer. |
| Serial | Serial.read() | Reads the next incoming byte from the serial buffer. |
| Interrupts | attachInterrupt(pin, isr, mode) | Runs a function automatically when a pin changes (RISING/FALLING/CHANGE). |
| Interrupts | detachInterrupt(pin) | Disables a previously attached interrupt on a pin. |
| Math | map(value, fromLo, fromHi, toLo, toHi) | Re-scales a value from one numeric range to another — the standard sensor-to-output scaling helper. |
| Math | constrain(value, min, max) | Clamps a value to stay within a given range. |
| Random | random(min, max) | Returns a pseudo-random long in the given range. |
| Structure | void setup() | Runs once at boot — the place for pinMode()/Serial.begin() calls. |
| Structure | void loop() | Runs continuously after setup() — the sketch's main body. |
arduino-cli Commands
| Command | Description |
|---|---|
arduino-cli board list | Lists connected boards and their detected port/FQBN. |
arduino-cli core install arduino:avr | Installs the platform core needed to compile for a given board family. |
arduino-cli sketch new MySketch | Scaffolds a new sketch folder with a starter .ino file. |
arduino-cli compile --fqbn arduino:avr:uno MySketch | Compiles a sketch for a specific board. |
arduino-cli upload -p /dev/ttyUSB0 --fqbn arduino:avr:uno MySketch | Uploads a compiled sketch to a board on the given serial port. |
arduino-cli lib install "Servo" | Installs a library by name from the Library Manager index. |
arduino-cli lib search keyword | Searches the library index for a keyword. |
arduino-cli monitor -p /dev/ttyUSB0 -c baudrate=9600 | Opens a serial monitor on the given port at a given baud rate. |
Arduino IDE Shortcuts
| Action | macOS | Windows |
|---|---|---|
| Verify / Compile | ⌘R | Ctrl+R |
| Upload | ⌘U | Ctrl+U |
| Serial Monitor | ⌘⇧M | Ctrl+Shift+M |
| Serial Plotter | ⌘⇧L | Ctrl+Shift+L |
| New Sketch | ⌘N | Ctrl+N |
Wiring Basics
Breadboard Rails
The two outer rows on each side are power rails (+ and −), shared along the whole strip — the inner rows are grouped in short 5-hole columns, not connected across the center gap.
Pull-up / Pull-down Resistors
A floating digital input reads noise — a resistor to 5V (pull-up) or GND (pull-down) gives it a defined rest state. Most boards support INPUT_PULLUP in software, skipping the physical resistor.
Current-Limiting Resistors
An LED wired directly to a pin will draw too much current and burn out — a ~220Ω-330Ω series resistor is the standard safe default for a 5V pin.
Common Ground
Every component and power source in a circuit needs a shared GND reference — a very common "nothing works" bug is simply a missing ground connection between the board and an external power supply.
Quick Tips
volatile, or the compiler may cache a stale value in the main loop.~ on the board silkscreen — check the specific board's pinout before wiring a dimmable LED or motor driver.