All articles

    What Is a Microcontroller? And Should I Choose an Arduino or an ESP32?

    The microcontroller explained for beginners: a tiny computer on a chip with a processor, memory, inputs and outputs, how it differs from a processor and a Raspberry Pi, how the program runs (setup and loop), digital and analogue inputs and outputs and PWM, memory in numbers, and the difference between the Arduino Uno, ESP32 and Raspberry Pi Pico.

    Updated 5 min read

    A microcontroller is a very small computer on a single chip: it has a processor, memory, inputs and outputs. You write a program for it, and it reads sensors, makes decisions and switches things on. It's found in remote controls, washing machines, microwaves, cars and most electronics projects.

    What's inside?

    • The processor (CPU): runs the program.
    • Flash memory: the program is stored here and isn't erased when the power goes off.
    • RAM: for variables while running.
    • Peripherals: timers, an ADC, UART, I2C, SPI, and sometimes WiFi and Bluetooth.
    Inputs (sensors and buttons) go into the microcontroller, and it controls the outputs (an LED and a motor)
    Inputs (sensors and buttons) go into the microcontroller, and it controls the outputs (an LED and a motor)

    A microcontroller, a processor or a Raspberry Pi?

    MicrocontrollerComputer processorRaspberry Pi
    MemoryInside the chipExternalExternal (gigabytes)
    Operating systemNone, just your programWindows or LinuxLinux
    Starts inFractions of a secondSeconds to minutesSeconds
    ConsumptionMilliamps or lessMany watts2–5 W
    TimingPrecise and predictableNot guaranteedNot guaranteed

    So a microcontroller isn't a weak computer; it's a different tool: it does one thing precisely, and runs on a battery for months. A Raspberry Pi suits cases where you need a screen, a camera or large programs. And many projects use both: the Pi as the big brain, and the microcontroller for the sensors and motors.

    How does the program run?

    On the Arduino, the program has two parts:

    void setup() {
      pinMode(13, OUTPUT);     // runs once at power-up
    }
    
    void loop() {               // repeats until the power goes off
      digitalWrite(13, HIGH);
      delay(500);
      digitalWrite(13, LOW);
      delay(500);
    }
    • setup: the settings, once.
    • loop: the real work, looping forever. There's no "exiting" the program as on a computer.
    • delay stops everything. When the project grows, use millis instead of delay to do several things at once, and interrupts for fast events.

    If you haven't tried it yet, start with a first Arduino project.

    Pin types

    • Digital: either 0 or 1. Read a button or turn on an LED.
    • Analogue input: the ADC converts the voltage to a number, such as reading a potentiometer or a temperature sensor.
    • PWM: fast switching on and off in different proportions, to control the brightness of an LED or the speed of a motor.
    • Communications: UART, I2C and SPI for talking to sensors, displays and modules. The differences are in the protocols article.

    Memory in numbers

    Arduino UnoESP32
    Flash (the program)32 KBUsually 4 MB
    RAM (variables)Only 2 KBAbout 320 KB
    EEPROM1 KBEmulated in flash

    The Uno's 2 KB runs out quickly: strings in Serial.print eat RAM. Use F("text") so the string is stored in flash instead of RAM. And when RAM runs out, the program hangs in strange ways with no error message.

    A quick comparison

    Arduino UnoESP32Raspberry Pi Pico
    Voltage5 V3.3 V3.3 V
    Speed16 MHzUp to 240 MHz133 MHz
    WiFi / BluetoothNoYes, bothOnly on the Pico W
    Suited toStarting out and learningIoT and the smart homeFast, cheaper projects

    Our advice: if you're just starting, the Uno is easier at first and its projects are widespread. And if you want the project to connect to the internet or a phone, go straight to the ESP32. Getting started with it is in first steps with the ESP32.

    Things to know from the start

    • Voltage: the ESP32 runs on 3.3 V. If you connect a 5 V signal to its pin it may be damaged. Use a voltage divider or a level shifter.
    • Current: a pin can only supply a small current (milliamps). For a relay or motor use a transistor. The figures in detail are in Arduino pin limits.
    • The crystal: the chip's speed and timing accuracy come from a crystal or oscillator.
    • The battery: if the project runs on a battery, use sleep mode. The calculation is in the battery life article.
    • Power: each way of powering it has limits. See powering the Arduino.

    When something doesn't work

    • Start with Serial: print values as you go. See the Serial Monitor.
    • Test each part on its own: the sensor in a program by itself, the motor in a program by itself, then combine them.
    • Ground: any external module must share ground with the microcontroller.
    • The wrong pin: some pins have special functions at boot (especially on the ESP32), so check the pinout.

    From the board to the product

    A development board (such as an Arduino) has extra things: a regulator, a USB chip and LEDs. When the project is finished, you can design a PCB with only the chip and the parts you need, so it's smaller, cheaper and uses less power.

    FAQ

    Which language should I learn? Most projects use C/C++ in the Arduino IDE. The ESP32 and the Pico also support MicroPython, which is easier if you know Python, but slower and uses more memory.

    Is the Arduino a "microcontroller"? Arduino is the name of the board and the software. The microcontroller itself is the chip on it: on the Uno it's called the ATmega328P.

    Circuits Nerd
    © 2026 Circuits Nerd. All rights reserved.