Hello, Microcontroller
CPU, memory and peripherals on one chip — and your blinker rewritten as five lines you can change in seconds.
Builds on: 7.3 Memory & Counters7.2 Adding with Gates4.1 Build the Blinker
Unit 7, shipped as a product
You built an adder from gates and a counter from flip-flops. Scale that honest construction up a few million times, add program memory, and you get a microcontroller (MCU): a complete computer — CPU, flash for your program, RAM for its variables — plus peripherals whose pins touch the physical world. A Raspberry Pi Pico costs about $5 and contains two 133 MHz processors. The chip that got Apollo to the Moon would be embarrassed.
What the peripherals are, you already know from this course:
- GPIO — general-purpose pins your program can switch high/low: a transistor switch (3.2) per pin, under software command.
- Timers/PWM — your 555 and Unit 8 dimmer, in silicon, on any pin.
- ADC — the analog-to-digital converter, next lesson’s star.
- Serial ports — flip-flop shift registers that talk to other chips.
A program is a circuit you can edit
Firmware executes one line at a time, marched forward by the program counter — the very counter idea from Lesson 7.3, now pointing at instructions. The blink program below does exactly what your 555 capstone did. The difference is profound anyway: changing the 555’s blink rate meant swapping a physical capacitor; changing this one means editing the number 0.5. Hardware sets what a circuit can do; software decides what it does, and you can revise the decision after lunch.
MicroPython: the friendly on-ramp
Professionals often write MCU firmware in C, but the Pico happily runs MicroPython — real Python, on the chip, talking to pins. You type a line, the board executes it immediately; save a file called main.py and the board runs it at every power-up, computer no longer required. That workflow is the whole capstone setup, two lessons from now.
Your laptop runs an operating system juggling thousands of tasks. An MCU typically runs your program and nothing else, starting within milliseconds of power, for years, on milliwatts. That single-mindedness is why they hide in washing machines, cars (dozens each), toys and thermostats — over 30 billion are made every year.
⚡ Lab — Be the CPU
The real MicroPython blink program, executed line by highlighted line.
- Step through manually first: setup lines run once; the while-loop runs forever.
- Press Run and watch the program counter orbit the loop as the LED blinks.
- Note where the CPU spends almost all its time: asleep inside sleep(). Real firmware too.
from machine import Pinfrom time import sleep led = Pin(15, Pin.OUT) # GP15 drives the LED while True: led.on() sleep(0.5) led.off() sleep(0.5)