Arduino
Arduino is an open-source electronics platform that made microcontroller programming approachable for millions of students, artists, makers, and engineers. It combines inexpensive boards with standardized pin layouts, a simple programming model called the sketch, a cross-platform IDE, and an enormous ecosystem of libraries and add-on shields. In an afternoon, someone with no embedded experience can read a sensor, drive a motor, and send data over Wi-Fi.
That accessibility makes Arduino the default tool for prototypes, education, and small production runs. The same simplicity — global state, blocking delays, minimal structure — becomes a liability as projects grow. Knowing how the platform works underneath, and how to structure sketches as real firmware, lets you keep the benefits without the mess.
TL;DR
- Boards range from the classic Uno and Nano to the MKR, Nano ESP32, and industrial Portenta and Opta families.
- A sketch has
setup()(runs once) andloop()(runs forever), written in C++ with the Arduino core API. - Board cores extend Arduino to many chips, including ESP32 and RP2040; libraries cover sensors, displays, and protocols.
- Use
millis()-based timing instead ofdelay()so code stays responsive. - Mind memory limits — 2 KB of RAM on an Uno R3 — and avoid heavy dynamic allocation.
- For products, add structure, version control, CI builds with arduino-cli, and tests, or move to a vendor SDK or RTOS when needed.
Quick Example
A non-blocking sketch that blinks an LED and samples a sensor at different rates:
Building and uploading from the command line, the same way CI would:
Core Concepts
Boards
Third-party boards supported through board cores — ESP32, ESP8266, Raspberry Pi Pico (RP2040/RP2350), STM32 — vastly extend the range. See ESP32 and Microcontrollers.
The Sketch Model and Core API
The Arduino build system wraps your sketch in a main() that calls setup() once and then loop() repeatedly. The core API abstracts hardware behind portable functions:
Under the hood, sketches are C++ compiled with GCC for the board's architecture; nothing prevents using registers, vendor libraries, or plain C++ classes.
Libraries and Cores
The Library Manager installs libraries for sensors, displays, motors, networking, and protocols such as MQTT. Quality varies: check maintenance activity, supported architectures, memory use, and licenses. Cores (installed through the Boards Manager) provide the core API for each chip family.
Tooling
From Prototype to Maintainable Firmware
- Structure the code: move hardware drivers and logic into classes or modules in separate files; keep
loop()a short dispatcher. - Use state machines, not nested
delay()calls, so the device can react to inputs and timeouts at any time. - Pin dependencies: record core and library versions (
sketch.yamlprofiles or PlatformIO) for reproducible builds. - Build in CI with arduino-cli for every supported board, and run logic tests on the host.
- Handle failures: watchdog timers, sensor read errors, reconnection with backoff, and brownouts.
- Plan updates and security: secure over-the-air updates and credential storage for connected devices. See Firmware OTA Updates and IoT Security.
- Know when to move on: complex concurrency, strict real-time needs, or certification may call for a vendor SDK, an RTOS, or a custom board.
Best Practices
Prefer Non-Blocking Timing
Track time with millis() and compare intervals with unsigned subtraction; delay() freezes everything else, including input handling.
Keep Interrupt Handlers Tiny
Set flags or capture timestamps in interrupts, mark shared variables volatile, and do the real work in loop().
Watch Memory on Small Boards
Avoid String concatenation on AVR boards, store constant strings in flash with the F() macro, and check free RAM during development.
Debug With Evidence
Use the serial plotter, logic analyzers, and multimeters; many "software bugs" are wiring, power, or pull-up resistor problems.
Common Mistakes
delay() Everywhere
Floating Inputs
Ignoring Voltage Levels
FAQ
What is Arduino?
An open-source platform of microcontroller boards, a simplified C++ programming model, development tools, and libraries that makes it easy to build interactive electronics and prototypes.
What language does Arduino use?
C++ with the Arduino core API. Sketches are compiled with GCC for the target microcontroller, and standard C and C++ code can be used alongside Arduino functions.
Which Arduino board should I start with?
An Uno R4 (Minima or WiFi) is a common starting point thanks to its documentation and shield compatibility. For connected projects, boards with Wi-Fi such as the Uno R4 WiFi or Nano ESP32 are convenient.
Can Arduino be used in commercial products?
Yes, especially for small volumes and professional boards designed for it. Larger products often use the same microcontrollers on custom boards, with firmware structured for maintainability and certification.
What is the difference between Arduino and Raspberry Pi?
Arduino boards are microcontrollers that run a single program directly on the hardware with precise timing and low power. Raspberry Pi computers run a full Linux operating system and are better for networking, displays, and heavy computation. See Raspberry Pi.
Related Topics
- Microcontrollers — MCU fundamentals
- Embedded C — Low-level firmware programming
- ESP32 — Wi-Fi and Bluetooth microcontrollers often used with Arduino
- Raspberry Pi — Single-board Linux computers
- MQTT — Messaging for connected devices
- Embedded Systems & IoT — The wider embedded landscape
- I2C, SPI, and UART — Wiring and debugging I2C, SPI, and UART devices