Lesson 1 of 5 · 15 min
Raspberry Pi vs microcontroller
A Raspberry Pi has a row of pins and can blink an LED, just like an Arduino, so it is easy to think of it as a bigger Arduino. It is not. A Pi is a general purpose computer that happens to expose some pins, and an Arduino is a single-purpose controller that happens to run your code. Choosing the wrong one costs you either power, reliability, or weeks of fighting the wrong tool.
Two different kinds of machine
A microcontroller (MCU) runs one program, directly on the hardware, from the moment power arrives. There is no operating system. Your loop() owns the CPU, so a pin change happens exactly when the code says it should, down to a few microseconds.
A Raspberry Pi runs Linux. Your Python script is one process among dozens. The kernel scheduler decides when it runs, and it may pause your script for a millisecond or more to service the network, the SD card, or another process. That is called jitter, and it is the price of having a filesystem, Wi-Fi, a camera stack, and a package manager.
| Property | Microcontroller (Pico) | Raspberry Pi 5 |
|---|---|---|
| CPU | 2 cores, 133 MHz | 4 cores, 2.4 GHz |
| Memory | 264 KB | 4 GB to 16 GB |
| Boot time | Milliseconds | 15 to 30 seconds |
| Timing | Deterministic, microseconds | Jitter of milliseconds |
| Power draw | Tens of milliamps | 3 W idle, 10 W or more under load |
| Storage | Flash, survives power cuts | SD card, can corrupt on power cuts |
The memory gap is the real story: 264 KB against several gigabytes is a factor of about 15,000. That gap is what lets the Pi run OpenCV, a web server, and a speech recogniser, none of which fit on an MCU.
The boards you will meet
- Raspberry Pi 4: quad-core Cortex-A72 at 1.5 GHz, 1 to 8 GB RAM, powered by 5 V at 3 A over USB-C. The safe, well-documented default.
- Raspberry Pi 5: faster Cortex-A76 cores at 2.4 GHz, a power button, and it wants a 5 V at 5 A supply for full performance with USB peripherals.
- Raspberry Pi Zero 2 W: quad-core Cortex-A53 at 1 GHz but only 512 MB RAM. It is small, sips power, and has Wi-Fi. Good for a light robot that needs a camera, poor for heavy vision.
- Raspberry Pi Pico: this is not a Linux computer at all. It is an RP2040 microcontroller running MicroPython or C. Include it here because it is the right answer more often than people expect.
When to use which
Use a microcontroller when the job is a tight, timing-critical loop: driving motors with PWM, reading an encoder at 10 kHz, running a balance controller at 500 Hz. Use a Pi when the job needs software that only exists on a real operating system: computer vision, networking, a web dashboard, or logging to disk.
Most serious robots use both. The Pi plans and sees. The microcontroller handles motors and sensors in real time and talks to the Pi over USB serial. This split is worth remembering, because it lets each chip do the thing it is good at.
Power and SD card care
A Pi under-volted by a weak charger does not just reset. It throttles and corrupts data. A Pi 4 needs a real 5 V 3 A supply, and a Pi 5 needs a 5 A one. A lightning bolt icon on screen, or the command vcgencmd get_throttled returning anything other than 0x0, means the supply is too weak.
On a battery robot, a motor starting can pull the 5 V rail down for a few milliseconds. Power the Pi from a dedicated regulator, separate from the motors, and add a bulk capacitor if you see resets.
The SD card is the weakest part. Flash memory wears out with writes, and cutting power during a write can leave the filesystem half-updated. To stay safe:
- Buy a quality card (A1 or A2 rated, 16 GB or more) rather than the cheapest one.
- Never pull power while the green activity LED is flashing.
- Write logs sparingly. Logging a value 100 times a second to the card wears it quickly.
- Keep a backup image of a working card.
Headless setup with SSH
A robot has no monitor, so you set it up headless: no screen, keyboard, or mouse, only a network connection.
In Raspberry Pi Imager, choose your board and Raspberry Pi OS Lite, then open the settings before writing. Set a hostname (say robot), a username and password, your Wi-Fi name and password, and tick Enable SSH. These settings are written to the card, so the Pi joins your network on the first boot with no extra steps.
Boot the Pi, wait a minute, then connect from your laptop:
ssh pi@robot.local
Replace pi with the username you chose. You are now typing commands on the Pi. Improve security by switching to key login so you are not typing a password every time:
ssh-keygen -t ed25519
ssh-copy-id pi@robot.local
Shutting down safely
Linux keeps recent writes in memory and flushes them to the card later. Yanking the cable skips that flush. Always shut down properly:
sudo shutdown -h now
Wait until the green LED stops flashing, then remove power. For a robot that nobody will SSH into, you will later add a physical shutdown button, which is a good first GPIO project.
Check yourself
Why is a Raspberry Pi a poor choice for a loop that must toggle a pin every 100 microseconds with no variation?
Check yourself
What is the safest way to turn off a Pi running a robot program?