que-es-microcontrolador-arduino-esp32

What is a Microcontroller: Arduino, ESP32, and PIC

  • 4 min

A microcontroller is a complete programmable system within a single chip that integrates a CPU, memory, and input/output peripherals. It is the component that allows a circuit to change its behavior simply by modifying the firmware.

At this point, classic electronics meets computer science. Until now, if we wanted to make an LED blink, we would build a 555 timer circuit using resistors and capacitors calculated by hand. If we wanted to change the speed, we had to desolder and recalculate.

With a Microcontroller, we simply change a line of text on our computer, hit “Upload”, and the chip’s behavior changes completely.

But what exactly is that little black “roach” made of silicon? Is it the same as the i9 processor in your PC? Today we are going to dissect the brain of our projects.

Microprocessor vs. Microcontroller: They Are Not the Same

We often use the word “processor” for everything, but there is an important distinction.

The Microprocessor (CPU)

This is the chip you have in your computer (Intel Core, AMD Ryzen).

  • It is optimized to offer high computational power.
  • Problem: It is useless by itself. It needs external chips to function: RAM modules, a hard drive to store data, chipsets for USB, a graphics card, etc.
  • It is the brain, but without a body.

The Microcontroller (MCU)

It is a complete computer on a single chip (SoC - System on Chip). Inside that small plastic package you have:

  1. CPU: The brain (slower than a PC’s, but sufficient).
  2. RAM Memory: To store volatile variables.
  3. Flash Memory: Non-volatile memory where the program is stored.
  4. Peripherals: Pins and dedicated blocks to interact with the outside world.

Anatomy of an MCU

To understand how to program an Arduino or an ESP32, you need to know what parts they integrate. Everything we have seen in the previous modules is inside there, miniaturized:

  1. The Core: This is the ALU and the Control Unit. It executes instructions (add, subtract, move data, jump).
  2. Flash Memory (The Program): Your code is stored here. It is non-volatile memory, so it retains its contents when power is removed.
  3. SRAM (The Variables): Your variables live here (int counter = 0). It is “Volatile” memory, erased upon reset.
  4. GPIO (General Purpose Input/Output): These are the “legs” of the chip. We can configure them as inputs (reading sensors) or outputs (turning on LEDs) as desired.
  5. Specialized Peripherals: Dedicated hardware that frees the CPU from work:
    • Timers: Precise counters (based on flip-flops) for measuring time or generating PWM.
    • ADC: Converters for reading analog signals.
    • UART/SPI/I2C: Dedicated blocks for communicating with other chips.

The Major Families

In the world of maker and professional electronics, three names are constantly repeated.

AVR (The Heart of Arduino)

Manufactured by Atmel (now Microchip). The most famous is the ATmega328P (Arduino UNO/Nano).

  • Architecture: 8-bit.
  • Voltage: 5V (generally).
  • Advantages: Indestructible. It is very electrically robust. Ideal for learning because it tolerates many beginner errors.
  • Disadvantages: Slow (16 MHz) and with little memory.

ESP32 and ESP8266

Manufactured by Espressif. They have changed the market over the last decade.

  • Architecture: 32-bit; depending on the family, it can be Xtensa or RISC-V.
  • Voltage: 3.3V (Caution, they are not 5V!).
  • Advantages: Brutal power (240 MHz, dual-core), integrated WiFi and Bluetooth. It is the current standard for IoT.
  • Disadvantages: Their pins are more delicate (easily burned by 5V) and the chip is more complex.

PIC (The Industrial Veterans)

Manufactured by Microchip. They were the undisputed kings for decades.

  • Although they have lost ground to Arduino in the maker world, they remain ubiquitous in household appliances (washing machines, microwaves) and industrial environments due to their robustness against electromagnetic noise.

ARM (STM32, RP2040)

The ARM Cortex-M architecture appears in many microcontroller families. Chips like STM32 or RP2040 offer more resources for projects that exceed the capabilities of a basic AVR.

From Hardware to Firmware

The most important thing you must understand is the paradigm shift. In the previous modules, if we wanted to make an AND gate, we connected transistors. The behavior was defined by physics.

Now, we connect a microcontroller and the behavior is defined by the Firmware (Embedded Software).

  • We can make Pin 1 an input now, and an output 10 milliseconds later.
  • We can simulate thousands of logic gates using code (if, else, and, or).

The hardware becomes generic; the software gives it its personality.