Microcontrollers 101

The tiny brain inside everything.

An interactive guide to microcontrollers. Take an ESP32 apart, see how it thinks, then write code that runs on it — right here in your browser.

Meet the star of the show

This is an ESP32.

A board about the size of a matchbox. It costs less than a pizza — and it can run robots, read sensors and talk over Wi-Fi.

  • 240MHz · 2 cores
  • 520KB of fast memory
  • 34programmable pins
  • Wi-Fi+ Bluetooth built in
Scroll to begin
ESP32 DevKit board

Chapter 01

What is a microcontroller?

Every time you press a button on a microwave, a toy lights up, or a drone holds itself steady in the air, a tiny computer is making decisions. That computer is a microcontroller.

01 / 04

A whole computer on one chip.

A laptop spreads its brain, memory and connections over many chips on a big board. A microcontroller squeezes all of them into a single chip smaller than your fingernail.

02 / 04

Brain, memory and senses.

  • Processorfollows instructions, one tiny step at a time
  • Memoryremembers your program and its numbers
  • Input / Output pinsfeel the world (buttons, sensors) and act on it (lights, motors)

03 / 04

It runs one job, forever.

Your phone juggles hundreds of apps. A microcontroller usually runs a single program, starting the instant it gets power and repeating it until the power goes off — thousands of times every second.

04 / 04

Small, cheap, and incredibly efficient.

LaptopESP32
Starts up in~20 secondsunder 1 second
Power used~45 watts~0.5 watts
Asleep, uses~1 watt0.00003 watts
Costs about$600+$5

Look around you

They're hiding in everything.

Tap a device to see what its microcontroller is doing.

Pick a device above.

Chapter 02

Meet the ESP32 DevKit.

The ESP32 chip doesn't work alone. It sits on a small board with everything it needs: power, a USB port to talk to your computer, buttons, a light and rows of pins. Let's walk around it, part by part.

01 · The brain

ESP32-WROOM-32 module

The silver box is a metal shield. Hidden underneath is the ESP32 chip itself, plus its memory. The shield blocks radio noise so the chip and its Wi-Fi don't interfere with each other.

Think of it as: the brain, wearing a helmet.

Deeper dive

Inside: an ESP32-D0WDQ6 chip with two Xtensa LX6 processor cores at up to 240 MHz, 520 KB of SRAM, a 4 MB SPI flash chip for your program, and a 40 MHz crystal that sets the timing. You'll lift the shield off in Chapter 3.

02 · Wireless

PCB antenna

That gold zig-zag isn't decoration — it's the Wi-Fi and Bluetooth antenna, printed straight onto the board. Its exact length is tuned to catch 2.4 GHz radio waves.

Think of it as: the board's ears and mouth for radio.

Deeper dive

It's a "meandered inverted-F" antenna. Folding the trace saves space while keeping its electrical length near a quarter wavelength (about 3 cm at 2.4 GHz). Keep metal and your fingers away from it for the best range.

03 · Power + data

Micro-USB port

One cable does two jobs: it powers the board with 5 volts, and it carries your program from the computer to the chip.

Think of it as: the lunchbox and the letterbox in one.

04 · Translator

CP2102 USB-to-UART chip

Your computer speaks USB. The ESP32 speaks a simpler language called serial (UART). This little chip translates between them — so you can upload code and read messages from your program.

Think of it as: an interpreter at a meeting.

Deeper dive

It also flips the EN and BOOT lines automatically during an upload, so you rarely need to press the buttons yourself. Some boards use a CH340 chip for the same job.

05 · Power

AMS1117 voltage regulator

USB gives 5 V, but the ESP32 needs exactly 3.3 V — more would damage it. The regulator steps the voltage down and holds it steady.

Think of it as: a dam that lets out a calm, steady stream.

Deeper dive

It's a linear regulator: it "burns off" the extra 1.7 V as a little heat. It can supply around 800 mA. Important: the ESP32's pins are 3.3 V only — never connect 5 V signals directly to them.

06 · Restart

EN button (reset)

Pressing EN switches the chip off for a moment and back on, so your program starts again from the very beginning.

Think of it as: the restart button on a game console.

07 · Upload mode

BOOT button

Hold BOOT while the board restarts and the ESP32 waits for new code instead of running the old program. Your programs can also read it as an ordinary button (it's connected to pin 0).

Think of it as: "Don't start yet — new instructions coming!"

08 · Lights

Power + built-in LEDs

The red LED means the board has power. The blue one is connected to pin 2, so your code can switch it on and off — perfect for your very first program.

Try it: tap the blue LED's button below.

09 · Connections

38 header pins

These metal legs plug into a breadboard. Some give power (3V3, 5V, GND); most are GPIO pins — "general-purpose input/output" — that your program can read from or switch on and off.

Think of it as: the board's hands and nerves.

Deeper dive

Pins 34–39 can only read (input only). Pins 0, 2, 5, 12 and 15 are "strapping pins" that set the chip's start-up mode, so use them with care. Some pins can also do analog input, touch sensing, PWM and serial communication.

Your turn

Explore it yourself.

Drag the board to spin it around. Tap any dot to jump back to that part.

ESP32 DevKit board

Chapter 03

Inside the chip.

Time to lift the lid. Under the metal shield live three things that make the whole board work: the brain, the memory that stores your program, and a crystal that keeps the beat.

The brain

ESP32 system-on-chip

Two processor cores, fast memory, the Wi-Fi radio and all the pin controls — on one piece of silicon 5 mm wide.

The notebook

4 MB flash memory

Your program lives here. Like a USB stick, it remembers everything even when the power is off.

The heartbeat

40 MHz crystal

A tiny slice of quartz that vibrates exactly 40 million times a second. Every action in the chip happens in step with this beat.

ESP32 DevKit board

Zoom in further

One chip, many teams.

Engineers divide the silicon into areas, each with its own job. This is a simplified map of the ESP32. Tap a block.

Tap a block

Each coloured outline is a different part of the chip.

CPU CORE 0Xtensa LX6 CPU CORE 1Xtensa LX6 ULPlow-power helper ROM 448 KBboot code SRAM · 520 KBworking memory RADIOWi-Fi · Bluetooth PIN CONTROLGPIO · ADC · DACPWM · Touch COMMSUART · I²CSPI

Lab · The heartbeat

How fast is 240 MHz?

The crystal's beat drives a clock. On every tick the processor does one small step. Drag the slider from a slow tick up to the ESP32's real speed.

Speed1 Hz

Ticks in one blink of an eye0

One tick every second. You could count along.

Lab · How it thinks

Fetch. Decode. Execute.

Your program becomes a list of very simple instructions. The processor repeats three moves for each one, over and over. Step through a program that blinks an LED.

    FetchDecodeExecute

    Press Step to fetch the first instruction.

    PC0

    R10

    GPIO2LOW

    Deeper dive

    Real ESP32 instructions are binary numbers (Xtensa machine code). The "PC" (program counter) is a register that holds the address of the next instruction. A JUMP simply changes the PC, which is how loops work. The ESP32 overlaps these stages in a pipeline, so it finishes about one instruction per tick.

    Chapter 04

    Pins: how it feels and acts.

    A microcontroller only sees electricity. Inside, everything becomes a voltage — and a voltage becomes a number your program can use. Here are the four tricks every pin can do.

    Lab 1 · Digital output

    Switch something on.

    An output pin is either HIGH (3.3 V) or LOW (0 V). Flip it and watch the current flow.

    digitalWrite(4, LOW);

    Pin0.0 V

    Lab 2 · Digital input

    Feel a button press.

    An input pin reads the voltage on it. A "pull-up" keeps it HIGH until the button connects it to ground.

    digitalRead(15) → HIGH

    Pin3.3 V

    Lab 3 · Analog input

    Measure "how much".

    Some pins can measure any voltage between 0 and 3.3 V. The ADC turns it into a number from 0 to 4095.

    Voltage1.65 V

    analogRead(34) → 2048

    12 bits = 4,096 possible values

    Lab 4 · PWM output

    Fake a dimmer.

    A digital pin can only be fully on or off. The trick: flick it on and off thousands of times a second. More "on" time = brighter.

    analogWrite(4, 64);

    On 25% of the time

    Chapter 05

    The life of a program.

    You write words. The chip only understands numbers. Follow one program on its journey from your keyboard to a blinking light.

    1. You write the code.

    In the Arduino IDE you write instructions in C++, a language people can read.

    void setup() {
      pinMode(2, OUTPUT);
    }
    void loop() {
      digitalWrite(2, HIGH);
      delay(500);
      digitalWrite(2, LOW);
      delay(500);
    }

    2. The compiler translates it.

    A program called a compiler turns your words into machine code: the binary numbers the ESP32's processor actually runs.

    3. It travels down the USB cable.

    The CP2102 chip on the board receives the bytes as a fast serial stream — about 115,000 bytes every second.

    4. It's saved into flash.

    The program is written into the 4 MB flash chip. It stays there even with the power off — unplug it and plug it back in, and your program is still there.

    5. setup() runs — once.

    The board resets, and your setup() function runs a single time. It's for getting ready: choosing which pins are inputs and which are outputs.

    6. loop() runs — forever.

    Then loop() starts, and when it reaches the end it simply starts again. Round and round, until the power goes off.

    Chapter 06

    Your turn. Code it.

    This is a virtual ESP32 on a breadboard. Write real Arduino code on the left, press Run, and watch it come alive on the right.

    sketch.ino

    Serial monitor · 115200 baud

    
                  
    Code you can use here
    • pinMode(pin, OUTPUT | INPUT | INPUT_PULLUP)
    • digitalWrite(pin, HIGH | LOW) · digitalRead(pin)
    • analogRead(34) → 0–4095 · analogWrite(4, 0–255)
    • delay(ms) · millis() · map() · constrain() · random()
    • Serial.begin(115200) · Serial.print() · Serial.println()
    • Pins on this bench: 2 blue LED (on board) · 4 red LED · 15 button · 34 knob

    Lesson complete

    You're an ESP32 Explorer.

    You answered the checkpoints.

    Keep coding See our events