Skip to content

Parts academy

Meet every component before you wire it. Each illustration is drawn to show the thing that actually matters when you are holding the part: which leg is which.

The components

Quick quiz: name that part

Labeled diagram of a resistor showing colour bands and leadsbrownblackredgold1 kΩ, four bandsNo polarity: either way round is fine.

Question 1 of 6 · score 0

Which part is this?

The breadboard

The single most useful thing to understand in this whole course. Click a hole below and the app highlights only the holes genuinely joined to it.

Breadboard anatomypower rails: often split into sections, never assume continuityabcdethe trenchfga-e in one column are joined. f-j are joined separately. The trench keeps them apart.
abcde|fghij
1
2
3
4
5
6
7
8
9
10

Click any hole to see exactly which other holes it is joined to.

The long side rails are often split into two or more sections, so a rail may not run the whole length of the board. Never assume continuity along a rail: check it, or avoid relying on it by running a jumper straight to physical pin 38 as this course does.

Resistor estimator

How much current will flow through a red LED on a 3.3 V pin? Pick a resistor and see.

I = (3.3 V − 2 V) / 1000 Ω = 1.3 mA

The course value. Gentle on the pin, bright enough indoors, and the same part for every LED so you never have to wonder.

Four-band colours
brown, black, red, gold
Five-band colours
brown, black, black, brown, brown
  • These numbers assume a red LED with a forward voltage drop of about 2.0 V, driven from a 3.3 V pin.
  • The formula is I = (3.3 V - 2.0 V) / R. Different coloured LEDs drop different voltages, so the current changes a little.
  • Every mission in this course uses 1 kΩ for every LED. Never connect an LED with no resistor at all.

Glossary

Voltage
Electrical push, measured in volts (V).
Voltage is the difference in electrical pressure between two points. It is always a comparison, never a single place, which is why every circuit needs a ground to compare against. The Pico's pins work at 3.3 V.
Current
The flow of electricity, measured in amps (A) or milliamps (mA).
Current is how much electricity is actually moving through a wire each second. Our LEDs use about 1.3 mA. A servo motor can use several hundred milliamps, which is why it needs its own power supply.
Resistance
How much a part slows current down, measured in ohms (Ω).
Resistance limits current. Ohm's law ties the three together: current = voltage divided by resistance. A 1 kΩ resistor with 1.3 V across it allows 1.3 mA to flow. Bigger resistance means less current and a dimmer LED.
Ground
The 0 V reference everything is measured against.
Ground is the agreed zero point of a circuit. Every mission here uses physical pin 38 as ground. When two power systems must talk to each other, like the Pico and an external servo supply, their grounds must be joined or neither can understand the other's signals.
Signal
A voltage that carries information rather than power.
A signal wire tells something what to do. The servo signal wire carries tiny pulses and almost no current; the servo's power comes from a completely different wire. Confusing signal with power is one of the most common beginner mistakes.
Input and output
Output pins push voltage; input pins measure it.
An output pin decides its own voltage: on means about 3.3 V, off means about 0 V. An input pin measures whatever is there and reports it. A digital input reports 1 or 0; an analog input reports a number across a range.
Pull-up resistor
A gentle tie to 3.3 V so an unconnected input is not random.
An input with nothing attached floats and reports noise. A pull-up holds it at 1 when nothing else is happening. A button to ground then pulls it down to 0 when pressed, which is why released reads 1 and pressed reads 0.
Duty cycle
The fraction of each fast switching cycle that a pin is on.
Used by PWM. At 50 percent duty the pin is high for half of every cycle. The pin voltage is still only ever 0 V or 3.3 V; the apparent dimming happens because your eye averages the fast switching.
Analog to digital converter (ADC)
The part that turns a voltage into a number.
On a Pico W, GP26, GP27 and GP28 can do this. MicroPython's read_u16 reports 0 to 65535, but the underlying converter is 12-bit, so the last digits always wobble a little.
Hysteresis
Two thresholds with a dead band so a switch stops flickering.
Switch on below a low threshold, off above a high one, and change nothing in between. Thermostats and fridges work this way. It is the fix for a measurement that hovers right at a single decision line.
Debounce
Ignoring the electrical chatter of a mechanical switch.
Metal contacts bounce microscopically as they close, so one press can look like several. Waiting a few tens of milliseconds, and waiting for the release, turns the mess into one clean event.
Clamp
Forcing a value into a safe range before using it.
max(1200, min(1800, pulse)) guarantees the servo is never asked for anything outside its gentle window, however wrong the arithmetic that produced the number was.

Python you will use

  • Variables remember things

    pulse = 1500
    name = "flap"
    opened = False

    A variable is a labelled box. Numbers, text in quotes, and True/False all go in boxes the same way. The name on the left, the value on the right.

  • Printing to the Shell

    print("reading:", reading, "pulse:", pulse)

    print shows you what the board is thinking. Separate items with commas and print adds spaces between them. This is your main debugging tool.

  • Indentation makes blocks

    if reading < LOW:
        lit = True
        print("dark")

    Python uses indentation, not brackets. Everything indented under the if belongs to it. Mixing tabs and spaces is the classic cause of IndentationError.

  • if, elif, else

    if reading < LOW:
        lit = True
    elif reading > HIGH:
        lit = False
    else:
        pass

    Choices are checked in order and only the first matching branch runs. Leaving out the else on purpose, as in the nightlight, means 'do nothing and keep what you had'.

  • Counting loops

    for flash in range(3):
        led.on()
        time.sleep(0.15)
        led.off()
        time.sleep(0.15)

    range(3) gives 0, 1, 2, so the block runs three times. Put a loop inside a loop and the inner one runs fully on every step of the outer one.

  • Forever loops

    while True:
        reading = button.value()
        time.sleep_ms(10)

    while True runs until you stop it. Almost every program that watches an input uses one. Always include a small sleep so the loop does not hog the processor.

  • Functions package up work

    def command_us(pulse):
        pulse = max(1200, min(1800, int(pulse)))
        servo.duty_ns(pulse * 1000)

    def names a block you can call many times. Put a safety rule inside a function and it can never be forgotten at a call site.

  • try and finally

    try:
        led.on()
        time.sleep(10)
    finally:
        led.off()

    finally always runs, even when you press stop or an error happens. It is how we guarantee the hardware is left safe.

  • Comparisons and logic

    if reading == 0 and opened:
        print("pressed while open")

    One equals sign assigns a value; two equals signs ask a question. and, or and not combine conditions.

  • Integer division

    pulse = 1200 + reading * 600 // 65535

    // divides and throws away the fraction. Always multiply before dividing, or the fraction is lost before it can help you.

Exploring the rest of the kit later

The kit contains far more than this course uses. Here is what to know before you try the tempting ones. In each case follow the manufacturer's published wiring; this course does not invent drop-in circuits for them.

  • Buzzers

    The kit's active buzzer draws more current than a GPIO pin should supply directly, so it needs the transistor driver circuit specified in the Freenove documentation. Follow their published wiring rather than inventing a direct connection.

    Freenove tutorial
  • Ultrasonic distance sensors

    A 5 V ultrasonic module's echo output can be 5 V, and a Pico GPIO pin must never see 5 V. The echo line needs a proper voltage reduction to 3.3 V, done the way the module's documentation specifies. Do not connect echo straight to a GPIO pin.

    Freenove tutorial
  • Motors and relays

    DC motors, stepper motors and relays all need driver circuits of their own, plus a separate power supply, exactly like the servo in Mission 09. They cannot be driven from a GPIO pin.

    Freenove tutorial
  • Household mains electricity

    Nothing in this course or in the kit goes anywhere near mains voltage. Mains wiring is not a hobby project and is not covered here at any level.