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 oneAbbreviationOften called MCUDifference from a PCA microcontroller usually handles exactly one fixed task, instead of running many different programs at onceWhere microcontrollers are used
HouseholdWashing machines, microwaves, coffee makersVehiclesAirbags, ABS, engine controlSmall devicesRemote controls, keyboards, digital clocksSmart homeSmart plugs, thermostats and sensors with their own small chipMemory types
ROMMemory that can't be changed anymore after manufacturingEPROMA predecessor of flash, could be erased with UV light and rewritten, barely used todayOTPOne Time Programmable, can be written exactly once and never changed after thatFlashElectrically rewritable memory, the standard on most microcontrollers todayRAMWorking memory for ongoing calculations, its contents are lost when powered offChip architectures
4 bitVery simple and cheap, enough for something like a basic clock8 bitBy far the most widely used architecture for microcontrollers16 bitMore performance while power use stays manageable32 bitThe standard today for more demanding tasks, including on the ESP32Memory 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 megabytesWorking memory (RAM)Typically between 32 bytes and 48 kilobytesFor comparisonA regular PC often has 16,000 megabytes of RAM or moreProgramming languages
CBy far the most common language for microcontrollers in industryAssemblyA very hardware close language, mainly used on small, simple chipsMicroPythonA simplified version of Python made for microcontrollers, popular with beginners and hobby projectsWell known beginner platforms
ArduinoA very beginner friendly board with a large community and many ready made examplesESP32An affordable microcontroller with built in Wi-Fi and Bluetooth, often programmed with MicroPythonRaspberry Pi PicoA small, inexpensive board, also commonly used with MicroPythonProgramming 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 usedDifference from PythonOnly includes a small part of the normal Python libraries, because there's little space on the chipREPLAn interactive command line where individual Python commands run immediatelyFirmware 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 codeIDEA program on the PC where you write the code and then transfer it to the microcontrollerDriverAn extra program on the PC that makes the USB connection to the microcontroller possible in the first placeGPIO 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 outputHIGH and LOWA pin only knows two states, voltage on or off, similar to a 1 or 01 (HIGH)Usually 3.3 volts on an ESP32, an LED connected to it lights up0 (LOW)0 volts, an LED connected to it stays darkTypical exampleTurning on an LED through an output, or reading a button through an inputI2C 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 signalAddressEvery connected component has its own fixed address, the microcontroller uses it to talk to that component specificallyAdvantageSeveral sensors and displays at once, without needing separate wires for each oneSPI 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 I2CChip selectA dedicated line per component, instead of an address like with I2C, picks which component is being addressed right nowTypical useDisplays and memory cards, whenever high speed mattersPWM
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 valueTypical useDimming an LED's brightness or controlling the speed of a small motorADC, 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 sensorDigitizingThe ADC converts that voltage into a fixed number that the code can then work withTypical useReading a potentiometer or querying an analog sensor like a light sensorExample: 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 pressureSSD1306A small OLED display, which can for example show the measured sensor valuesDriver libraryReady made code that handles the I2C communication, so you only need to call a few simple commands yourself