Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 37 ยท Boards and IDE

The Arduino IDE and CLI

Install and use the Arduino IDE 2 and the arduino-cli: select a board and port, install board packages and libraries, use the Serial Monitor, and fix common setup problems.

To get code onto a board you need a toolchain: an editor, a compiler for the board's chip, and an uploader. The Arduino IDE bundles all three behind a friendly window. The arduino-cli does the same from a terminal, which suits scripts, automated builds and editors such as VS Code. Both use the same cores and libraries, so what you learn applies to either.

The IDE and compiler run on your computer, not in a web page, so the commands below are shown read-only. The stand-ins here explain the part you can simulate: how names resolve and what the build steps do.

The Arduino IDE 2

Download the installer for your operating system from arduino.cc and install it. The window has:

  • Editor with syntax coloring and autocompletion.
  • Verify (checkmark): compiles without uploading. Use it constantly; it is cheap.
  • Upload (arrow): compiles and sends the program to the board.
  • Board and port selector at the top. The board must match the hardware, and the port is the serial device the board appears as (COM3 on Windows, /dev/ttyACM0 or /dev/ttyUSB0 on Linux, /dev/cu.usbmodem... on macOS).
  • Output panel with compiler messages and the memory report: "Sketch uses 924 bytes (2%) of program storage space."
  • Serial Monitor (magnifier icon): a window to read text the board prints and to send text back. Later chapters of this course cover serial communication in depth.

Boards Manager and Library Manager

The IDE only knows the classic AVR boards at first. For other chips, open Tools > Board > Boards Manager, search for the family (for example "esp32" or "Arduino SAMD Boards") and install it. This downloads the core: the compiler, the board definitions and the Arduino API implementation for that chip.

Libraries are installed in Sketch > Include Library > Manage Libraries. Search by name, choose a version and press Install. Libraries live in a folder named libraries under your Arduino sketchbook directory.

The sketch folder

A sketch is a folder containing a .ino file with the same name: Blink/Blink.ino. Extra .h, .cpp or additional .ino files in the folder are compiled with it. Multiple .ino files are joined into one in alphabetical order, with the main one first.

The arduino-cli

The CLI is a single program. Read-only examples of the commands you will use most:

Terminal
# one-time setup
arduino-cli config init
arduino-cli core update-index
arduino-cli core install arduino:avr

# find the board and port
arduino-cli board list

# create, compile and upload a sketch
arduino-cli sketch new Blink
arduino-cli compile --fqbn arduino:avr:uno Blink
arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:avr:uno Blink

# libraries
arduino-cli lib search servo
arduino-cli lib install "Servo"

# watch serial output
arduino-cli monitor -p /dev/ttyACM0 -c baudrate=9600

--fqbn is the fully qualified board name: vendor:architecture:board. arduino:avr:uno is the Uno, arduino:avr:nano is the Nano, and esp32:esp32:esp32 is a generic ESP32. arduino-cli board listall prints every installed name.

C Stand-in: parse a fully qualified board name

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

What compile really does

Pressing Verify runs several programs in a chain. Understanding the chain makes cryptic errors readable.

flowchart LR
    A["sketch.ino"] --> B["Preprocess<br/>add Arduino.h and prototypes"]
    B --> C["avr-g++<br/>compile to object files"]
    C --> D["Link with core<br/>and libraries"]
    D --> E["firmware.elf"]
    E --> F["objcopy<br/>to firmware.hex"]
    F --> G["avrdude uploads over USB serial"]

Figure: the build pipeline for an AVR board. Other chips use different tools, but the same stages.

The stand-in below mimics the size report the IDE prints after linking, using the Uno limits. It is a calculator, not a compiler:

C Stand-in: the memory report the IDE prints

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

Common setup problems

  • Board not detected. Try a data cable (some cables only charge), a different port, and check the USB-serial driver for clone boards.
  • Library not found. The error "no such file or directory" for a header means the library is missing; install it from the Library Manager and check the exact #include name.
  • Wrong core selected. Compile errors about unknown registers usually mean the board type does not match the code.
  • Slow first compile. The first build compiles the whole core; later builds reuse cached objects.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does the Verify button do?

    Verify compiles and reports errors and memory use; Upload also sends the program to the board.
  2. 2. What does the fqbn arduino:avr:uno identify?

    FQBN is vendor:architecture:board.
  3. 3. Where do you install support for an ESP32 board in the IDE?

    Cores for new chips are installed through Boards Manager (or arduino-cli core install).
  4. 4. In which order do build stages run?

    Objects are compiled, linked into an ELF, converted to a HEX file, and then uploaded.

Summary

  • The IDE offers Verify, Upload, a board and port selector, and a Serial Monitor.
  • Boards Manager installs cores for chip families; Library Manager installs libraries.
  • arduino-cli does everything from a terminal, using an FQBN such as arduino:avr:uno.
  • The build is preprocess, compile, link, convert, upload.
  • Missing drivers, charge-only cables and wrong board settings cause most setup trouble.

Next: Pinout and Power Pins