Lite / Building Machines That Respond / Week 19
A whole computer on one chip
Your washing machine, your bike light and a Mars rover's wheel all hide the same kind of tiny computer. What is inside it?
Why should I care?
There are far more microcontrollers in the world than laptops and phones put together: one in every remote control, toaster, car window and toy robot. Each one is a complete computer squeezed onto a chip that costs about the same as a chocolate bar and runs on a trickle of power. If you can program one, you can make almost any object respond to the world.
- Name the main parts of a microcontroller: CPU, flash memory, RAM, clock and peripherals.
- Explain what each part does using an everyday machine as the example.
- Explain why a machine uses a microcontroller rather than a laptop-style computer.
Predict
A microcontroller loses power and then switches back on. Its program is still there. Where was the program kept?
- In RAM, which forgets nothing
- In flash memory, which keeps data without power
- It downloads the program again from the internet
Guess first, then reveal
The program lives in **flash** memory, which keeps its contents with the power off (like a USB stick). **RAM** is fast working memory for variables, but it forgets everything when the power goes. Most microcontrollers have no internet connection at all.
Discover
Open Level 4 of the Virtual Computer and step through a program one instruction at a time. Each step is one fetch–execute cycle: notice where the instruction comes from (memory), where the working number lives (a register) and what decides which instruction comes next.
What the interactive shows (text version)
The Virtual Computer activity can be followed as a list: the program counter points to an instruction in memory; the CPU fetches it, decodes it and executes it (for example LOAD a number into a register or ADD); then the program counter moves on, or jumps if the instruction says so. Repeat until HALT.
Watch (optional)
Watch for: Listen for each part the video compares with a desktop computer, and write down which job each one does.
A chip maker's beginner tour that compares the parts of a microcontroller with the parts of an ordinary computer.
“What is a Microcontroller?” by Microchip Technology, Inc. (opens YouTube; streaming video uses a lot of data)
The video is optional. Everything you need is in this lesson's text.
Understand
Five parts, one chip
A microcontroller (MCU) packs a whole computer onto one chip. The CPU follows instructions one at a time. Flash memory stores the program, even with the power off. RAM holds the variables while it runs. The clock is a steady tick that keeps everything in step. Peripherals are small helper circuits for the outside world: pins that read buttons and drive LEDs, an ADC that measures voltages, timers that count time, and serial ports that talk to other chips.
Microcontroller or laptop?
A laptop processor is fast and general: it runs many programs, needs lots of separate memory chips and uses tens of watts. A microcontroller is small, cheap and dedicated: it runs one program forever, starts in a fraction of a second and can run for months on a coin cell. It is slower, but a washing machine does not need to edit video; it needs to read a door switch reliably, millions of times.
Following the instructions
The CPU repeats one cycle: fetch the next instruction from flash, decode what it means, execute it (add, compare, read a pin), then move on. A special register called the program counter remembers where it is. A jump instruction changes the program counter, which is how loops and decisions work underneath your code.
Explain it another way
Intuitive
Think of a microcontroller as a tiny kitchen. The recipe book is flash, the worktop is RAM, the cook is the CPU, the kitchen timer is the clock and the oven, tap and scales are the peripherals.
Technical
Typical small MCUs have tens to hundreds of kilobytes of flash and a few to a few hundred kilobytes of RAM, run at roughly 1–250 MHz and include GPIO, ADC, timers and serial peripherals (UART, I²C, SPI). Peripherals are controlled by writing numbers into special memory locations called registers.
Applied
A digital kitchen scale: a load sensor feeds the ADC peripheral, the CPU turns counts into grams, a timer blanks the display after a minute and the program sits in flash. The whole thing runs for a year on two AAA batteries.
Worked example 1
A bike light flashes, reads a button and dims when the battery is low. Which microcontroller parts are involved?
Flash holds the program. The CPU runs it. A timer peripheral sets the flash rhythm. A GPIO pin reads the button and another drives the LED. The ADC measures the battery voltage. RAM holds variables such as the current mode.
Common mix-ups
A microcontroller is just a slow, cheap laptop chip.
✓ It is designed differently: memory, clock and peripherals are built in, so one chip can run a machine by itself.RAM and flash are the same thing.
✓ Flash keeps the program with the power off; RAM is fast working memory that forgets on power-down.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
Apply it
Pick a machine at home (microwave, kettle, toy, alarm clock). Draw a box for the microcontroller with its five parts, then draw arrows to every button, sensor, light and motor you think it uses. Label which peripheral each arrow connects to.
Reflect
Which part of the microcontroller surprised you most, and what would a machine lose without it?
Write your answer on paper or in your own notes. Lite never stores what you write.