Cheat Sheet Library

Arduino IDE Cheat Sheet

Shortcuts for Arduino IDE 2.x on Windows / Linux (macOS: Ctrl → ⌘), plus the most used Arduino functions.

  • 47 entries
  • 9 sections
  • Updated

47 entries

On this page

IDE Shortcuts #

ShortcutAction
Ctrl + RVerify / compile
Ctrl + UUpload
Ctrl + Shift + UUpload using a programmer
Ctrl + Shift + MSerial Monitor
Ctrl + TAuto format
Ctrl + /Comment / uncomment
Ctrl + SpaceAutocomplete
Ctrl + clickGo to definition
Ctrl + FFind / replace
Ctrl + Shift + ILibrary Manager
Ctrl + Shift + BBoards Manager
Ctrl + Alt + SExport compiled binary
Ctrl + KShow the sketch folder
Ctrl + ,Preferences
Ctrl + N / Ctrl + O / Ctrl + SNew / open / save

Sketch Structure #

const int LED = 13;

void setup() {             // runs once
  pinMode(LED, OUTPUT);
  Serial.begin(115200);
}

void loop() {              // runs forever
  digitalWrite(LED, HIGH);
  delay(500);
  digitalWrite(LED, LOW);
  delay(500);
}

Pins #

FunctionUse
pinMode(pin, OUTPUT / INPUT / INPUT_PULLUP)Set the pin mode
digitalWrite(pin, HIGH / LOW)Output on / off
digitalRead(pin)Read HIGH / LOW
analogRead(pin)0–1023 (Uno, 10-bit) / 0–4095 (ESP32, 12-bit)
analogWrite(pin, 0–255)PWM output (LED brightness, motor speed)
attachInterrupt(digitalPinToInterrupt(pin), isr, RISING)Run a function on a pin change

Time #

FunctionUse
delay(ms)Pause (blocks everything)
millis()Milliseconds since start (non-blocking timing)
micros()Microseconds since start
unsigned long last = 0;
void loop() {
  if (millis() - last >= 1000) {   // every second, without delay()
    last = millis();
    Serial.println("tick");
  }
}

Serial #

FunctionUse
Serial.begin(115200)Start (match the baud rate in the monitor!)
Serial.print(x) / Serial.println(x)Print / print + newline
Serial.printf("T=%.1f\n", t)Formatted print (ESP32 / ESP8266)
Serial.available()Bytes waiting to be read
Serial.read() / Serial.readStringUntil('\n')Read input

Math & Helpers #

FunctionUse
map(x, 0, 1023, 0, 255)Re-scale a value
constrain(x, 0, 100)Clamp
random(min, max)Random number (randomSeed(analogRead(A0)) first)
tone(pin, freq, ms) / noTone(pin)Buzzer
F("text")Keep strings in flash, saves RAM on AVR

Communication Libraries #

LibraryUse
Wire.hI²C (sensors, OLED displays): Wire.begin()
SPI.hSPI (SD cards, TFT displays)
WiFi.hWi-Fi on ESP32
EEPROM.h / Preferences.hStore data permanently (AVR / ESP32)

Data Types #

TypeAVR (Uno)ESP32
int16-bit32-bit
long32-bit32-bit
float / double32-bit / 32-bit32-bit / 64-bit
uint8_t, int16_t, uint32_tExact sizes, use these when it matters

Boards & Troubleshooting #

Problem / taskFix
Add ESP32 boardsPreferences → Additional boards URLs: https://espressif.github.io/arduino-esp32/package_esp32_index.json → Boards Manager → install esp32
No port shows upInstall the USB driver (CH340 or CP210x), try another (data) cable
ESP32 "Failed to connect"Hold the BOOT button when "Connecting…" appears
Garbage in Serial MonitorBaud rate doesn't match Serial.begin()
Sketch too big / low memoryUse F() strings, smaller types, fewer libraries