← Course overview
Week 1 of 12 · Foundations

Python & Project Setup

Get a Raspberry Pi talking to your laptop, and get comfortable writing and running Python before any hardware is involved.

~4 hrs Laptop + Pi

Concept Why we start here

The finished machine is, underneath everything, a Python program reading sensors and driving motors. Before touching a single wire, it's worth being able to write a small program, run it, and read what went wrong when it doesn't work — that skill gets used every single week from here on. We also set up a habit that saves a lot of friction later: the Pi runs headless (no screen of its own), and you write code on your own laptop but run it on the Pi itself, over the network, using VS Code's Remote-SSH.

Kit What you need this week

  • Raspberry Pi Zero 2 W + SD card (16GB+)
  • 40-pin header (soldered on) and a short GPIO extension cable — the Motor HAT is sized for the full-size Pi, not the Zero's footprint
  • Official Pi power supply (micro-USB, 2.5A+)
  • Your own laptop
  • A micro-USB OTG adapter, monitor, keyboard & mouse (just for first boot troubleshooting, if needed)
  • Wi-Fi network details

Build Step by step

Step 1

Flash Raspberry Pi OS

Install the Raspberry Pi Imager on your laptop. Choose “Raspberry Pi OS (64-bit)”, pick your SD card, then click the gear icon (advanced options) before writing — set a hostname (e.g. skittles.local), enable SSH, and set a username/password. This one dialog is what makes the Pi bootable straight into a network-ready state with no monitor needed.

Step 2

First boot

Insert the SD card, power the Pi on, and give it about a minute. From your laptop, try:

ping skittles.local
Step 3

SSH in

Once it responds to ping, connect over SSH:

  • If it refuses to connect, double-check the hostname and that SSH was actually ticked in the imager.
  • Accept the fingerprint prompt the first time — that's normal.
ssh yourusername@skittles.local
Step 4

Connect VS Code

Install VS Code and the “Remote - SSH” extension on your laptop. Use it to open a connection to yourusername@skittles.local. Once connected, open a terminal in VS Code — you are now typing commands that run on the Pi, not your laptop, even though the window is on your screen.

Step 5

Write your first script

Create hello.py and run it:

print("Hello from the Pi")
name = "Skittles"
print(f"Project: {name}")
Step 6

Loops

Print a multiplication table using a for loop — the same warm-up exercise from the project's own coding playground:

table_of = 3
for counter in range(1, 11):
    result = counter * table_of
    print(f"{table_of} x {counter} = {result}")
Step 7

Functions

Wrap logic in a function so it can be reused with different inputs:

def double(n):
    return n * 2

print(double(7))
print(double(21))
Step 8

Command-line arguments

Build a small unit converter that takes a value on the command line and prints the result — the same argparse pattern the colour classifier uses later in the course:

import argparse

ap = argparse.ArgumentParser()
ap.add_argument("--celsius", type=float, required=True)
args = ap.parse_args()

f = args.celsius * 9/5 + 32
print(f"{args.celsius}\u00b0C = {f}\u00b0F")
Step 9

Initialize Git Version Control

Real engineers never write code without version control. Initialize a local git repository in your project directory so you can record your progress and easily revert mistakes:

cd ~/skittles
git init
git config user.name "Elliot"
git config user.email "elliot@example.com"
git add .
git commit -m "Week 1: Setup completed and Python basics verified"
Why Git from Day 1?When your code breaks on Week 9 after modifying three different files, git diff will instantly highlight every line you changed, saving hours of guesswork.
Make it yours
  • Add a --unit flag so the script converts either C→F or F→C depending on what's passed in.
  • Make the script complain helpfully if no value is given, instead of crashing with a stack trace.
  • Give your machine a name, now, before it's even wired up. The original build is called “Entropy Reducer” — a nod to turning a randomly mixed bag of Skittles into neatly sorted piles (more on that idea in the course overview). Yours doesn't need a physics pun; it just needs to be yours.

If it breaks Troubleshooting

SSH connection refusedDouble-check the hostname/IP and that SSH was enabled in the imager's advanced options. Try the Pi's IP address instead of the hostname if .local resolution is flaky on your network.
“command not found: python”Raspberry Pi OS uses python3 explicitly — there usually isn't a plain python command.
Permission denied (publickey/password)Check you're using the exact username set in the imager — it defaults to something other than “pi” on recent images unless you set it yourself.
This week's checkpointThe Pi boots headless and accepts a remote VS Code session over SSH. You can write, run, and explain a function-based script with a command-line argument — without copying it line for line.
Next week: Electronics fundamentals — Ohm's law, breadboarding, and reading a switch through GPIO.