Microcontroller Basics

A tiny computer on a single chip, quietly doing its job inside countless everyday devices.

Last updated: September 23, 2026

What is a microcontroller

MicrocontrollerA complete small computer on a single chip, processor, memory and often inputs and outputs all in one
AbbreviationOften called MCU
Difference from a PCA microcontroller usually handles exactly one fixed task, instead of running many different programs at once

Where microcontrollers are used

HouseholdWashing machines, microwaves, coffee makers
VehiclesAirbags, ABS, engine control
Small devicesRemote controls, keyboards, digital clocks
Smart homeSmart plugs, thermostats and sensors with their own small chip

Memory types

ROMMemory that can't be changed anymore after manufacturing
EPROMA predecessor of flash, could be erased with UV light and rewritten, barely used today
OTPOne Time Programmable, can be written exactly once and never changed after that
FlashElectrically rewritable memory, the standard on most microcontrollers today
RAMWorking memory for ongoing calculations, its contents are lost when powered off

Chip architectures

4 bitVery simple and cheap, enough for something like a basic clock
8 bitBy far the most widely used architecture for microcontrollers
16 bitMore performance while power use stays manageable
32 bitThe standard today for more demanding tasks, including on the ESP32

Memory sizes compared

A microcontroller has far less memory than a regular computer, which is why the code has to be as lean as possible.

Program memoryTypically between 1 kilobyte and 2 megabytes
Working memory (RAM)Typically between 32 bytes and 48 kilobytes
For comparisonA regular PC often has 16,000 megabytes of RAM or more

Programming languages

CBy far the most common language for microcontrollers in industry
AssemblyA very hardware close language, mainly used on small, simple chips
MicroPythonA simplified version of Python made for microcontrollers, popular with beginners and hobby projects

Well known beginner platforms

ArduinoA very beginner friendly board with a large community and many ready made examples
ESP32An affordable microcontroller with built in Wi-Fi and Bluetooth, often programmed with MicroPython
Raspberry Pi PicoA small, inexpensive board, also commonly used with MicroPython
In practice

Programming an ESP32 with MicroPython

How a microcontroller is actually used in a hobby project, using the ESP32 as an example.

What is MicroPython

Its own lean programming language, based on Python but built specifically for microcontrollers with little memory.

AdvantageMuch easier to learn than C, the language otherwise commonly used
Difference from PythonOnly includes a small part of the normal Python libraries, because there's little space on the chip
REPLAn interactive command line where individual Python commands run immediately

Firmware and software

Before a microcontroller can run your own code, it needs some basic software first.

FirmwareThe base software that gets loaded onto the empty chip first, only after that does it understand, for example, Python code
IDEA program on the PC where you write the code and then transfer it to the microcontroller
DriverAn extra program on the PC that makes the USB connection to the microcontroller possible in the first place

GPIO pins

The connectors of a microcontroller through which it connects to the outside world.

GPIOGeneral Purpose Input Output, a freely usable connector for input or output
HIGH and LOWA pin only knows two states, voltage on or off, similar to a 1 or 0
1 (HIGH)Usually 3.3 volts on an ESP32, an LED connected to it lights up
0 (LOW)0 volts, an LED connected to it stays dark
Typical exampleTurning on an LED through an output, or reading a button through an input

I2C bus

A method for connecting several components to the microcontroller using just two wires.

SDA and SCLThe two lines of the I2C bus, one for data, one for the clock signal
AddressEvery connected component has its own fixed address, the microcontroller uses it to talk to that component specifically
AdvantageSeveral sensors and displays at once, without needing separate wires for each one

SPI bus

A second, faster method for connecting components to the microcontroller, often used as an alternative to I2C.

MOSI, MISO, SCKSeparate lines for sending, receiving and the clock signal, which makes it faster than I2C
Chip selectA dedicated line per component, instead of an address like with I2C, picks which component is being addressed right now
Typical useDisplays and memory cards, whenever high speed matters

PWM

Pulse width modulation, a trick for getting fine gradations out of a simple on/off pin.

How it worksThe pin switches very quickly between on and off, the ratio of the two times determines the effective value
Typical useDimming an LED's brightness or controlling the speed of a small motor

ADC, analog to digital converter

Converts an analog voltage into a number the microcontroller can work with.

Analog signalA voltage that can smoothly lie anywhere between two values, for example from a temperature sensor
DigitizingThe ADC converts that voltage into a fixed number that the code can then work with
Typical useReading a potentiometer or querying an analog sensor like a light sensor

Example: sensor and display

Two typical components connected to an ESP32 over I2C, each addressed through a ready made driver library.

BME280A sensor that measures temperature, humidity and air pressure
SSD1306A small OLED display, which can for example show the measured sensor values
Driver libraryReady made code that handles the I2C communication, so you only need to call a few simple commands yourself