Buying and naming parts
Every part in the shop has a Python class, generated from its catalogue entry. from wiring import * gives you all of them, named after the part: LED, Resistor, Button, Servo and so on. Creating a part buys it — its price goes on the bill and the part is laid out on the board.
from wiring import *
pi = Pi()
pi.GPIO17 >> Resistor(330) >> LED("red") >> pi.GND
pi.GPIO27 >> Part("resistor", 330) >> Part("led", "green") >> pi.GNDfrom gpiozero import LED
from time import sleep
red = LED(17)
green = LED(27)
while True:
red.on()
green.off()
sleep(0.5)
red.off()
green.on()
sleep(0.5)Settings
A part's main setting can be passed positionally; any setting can be passed by name:
Resistor(330) # the same as Resistor(ohms=330)
LED("red") # the same as LED(color="red")
Relay("high") # the same as Relay(trigger="high")
LED(color="green")
SlideSwitch(position="right")
Potentiometer(10000)
Only one positional argument is allowed, and only for parts that have a main setting. Settings are checked as they are set:
- an enum setting must be one of its listed options, and its value is compared as text, so
Potentiometer(10000)andPotentiometer("10000")both work; - a number setting must be a real number (a boolean is rejected) and lie inside its range —
Resistor(0)is an error because resistance runs from 1 Ω up; - an unknown setting raises a
CircuitErrornaming the settings that part does have.
A part with no main setting, like the button, takes no positional argument at all.
Any part by slug
Part("slug", …) is the generic constructor: it looks the slug up in the catalogue and builds the class that goes with it. It takes the same positional argument and settings as the class itself:
Part("dht22")
Part("resistor", 10000) # positional, like Resistor(10000)
Part("resistor", ohms=10000) # by name
Part("led", color="blue")
An unknown slug raises a CircuitError — shop() prints the catalogue below if you need the spelling.
Naming and placing
Both the generated classes and Part accept two extra keywords:
label="status"names the part: it is used in the part's id, in error messages and on the board;at=(80, 10)pins the part to a whole-cell grid position instead of letting the layout pick one.
status = LED("green", label="status")
res = Resistor(330, at=(20, 5))
at= takes a pair of whole numbers; anything else is a CircuitError.
The bill
Creating a part buys it. The bill feeds into the contest score, so the wiring you choose has a price; the boards themselves are free. The built-in kits are billed as one kit item instead of their parts — see Kits.
shop() prints every part and kit with its price, for when you are in the workspace and want the list:
shop() # every part and kit, one per line, with its price
The prices above and below come from the catalogue, so they always match the shop. A resistor costs $0.25, an LED $1, and a distance sensor $3.
Every part in the shop
Basics
Light
- LED — $1 — Needs a resistor in series (330 Ω) or it burns out.
- RGB LED — $2 — Three LEDs in one; each colour needs its own resistor.
- NeoPixel stick (8) — $7 — 8 addressable RGB LEDs on GPIO18. neopixel.NeoPixel.
- NeoPixel ring (12) — $10 — 12 addressable RGB LEDs on GPIO18.
Input
- Push button — $0.50 — Joins A to B while pressed. Use a pull-up or pull-down.
- Slide switch — $0.50 — COM joins pin 1 (left) or pin 2 (right).
- Potentiometer — $1.50 — A knob: the wiper W gives 0–3.3 V. Read it through an ADC.
- Rotary encoder — $3 — Endless knob with detents and a push switch (KY-040).
- 4×4 keypad — $4 — Rows R1–R4 × columns C1–C4. Scan it from Python.
Sensors
- Light sensor (LDR) — $0.75 — Resistance falls with light. Use a divider and an ADC.
- DHT22 temp & humidity — $5 — One-wire-ish data pin; needs a 10 kΩ pull-up. adafruit_dht.DHT22.
- DS18B20 thermometer — $4 — 1-Wire on GPIO4 with a 4.7 kΩ pull-up. /sys/bus/w1/devices.
- BME280 weather sensor — $8 — Temperature, humidity, pressure over I²C (0x76/0x77).
- MPU-6050 motion sensor — $6 — Accelerometer + gyro over I²C (0x68).
- HC-SR04 distance sensor — $3 — 5 V echo: divide it down before GPIO. gpiozero.DistanceSensor.
- PIR motion sensor — $4 — OUT goes high on motion. gpiozero.MotionSensor.
- Soil moisture sensor — $4 — Analog: wetter soil = lower voltage. Needs an ADC.
- MQ-2 gas sensor — $5 — DO goes low on gas (5 V module: divide it down).
- Sound sensor — $3 — DO goes high while it is loud.
- GPS module — $15 — NMEA sentences on the UART (/dev/serial0, 9600 baud).
- Camera module — $25 — Plugs into the CSI connector: wire CSI to pi.CSI. picamera2.
Chips
- MCP3008 ADC (SPI) — $4 — 8 analog inputs over SPI. gpiozero.MCP3008(channel=0).
- ADS1115 ADC (I²C) — $6 — 4 precise analog inputs over I²C (0x48).
Displays
- LCD 16×2 (I²C) — $9 — Two lines of text over I²C (0x27). RPLCD.i2c.CharLCD.
- OLED 128×64 (I²C) — $8 — Tiny graphics display (0x3C). adafruit_ssd1306.
- 4-digit display — $5 — Seven-segment digits on two GPIOs (CLK, DIO).
Sound
- Buzzer (active) — $1.50 — Beeps when powered. gpiozero.Buzzer.
- Buzzer (passive) — $1.50 — Plays the PWM frequency. gpiozero.TonalBuzzer.
Motion
- Servo — $5 — Angle from a PWM pulse on SIG. Power it from 5 V. gpiozero.AngularServo.
- DC motor + L298N — $12 — IN1/IN2 set direction, PWM on ENA sets speed.
- Stepper + ULN2003 — $8 — Step it by writing the coil sequence to IN1–IN4.
Power
- Relay module — $4 — Switches a load. Coil on DC+/DC−, signal on IN, contacts COM/NO/NC.
- Heater — $10 — Warms its room. Switch it with a relay.
- Fan — $6 — Airs its room. Switch it with a relay.
- Water pump — $8 — Waters the soil. Switch it with a relay.
- Lamp — $5 — Lights its room. Switch it with a relay.
- Breadboard power supply — $5 — Separate 5 V / 3.3 V rails for hungry parts.
Each entry links to the part's own page: what it is, its pins, a wiring example and how to drive it from main.py. The pages live under the Hardware section, and each one shows the generated pin table and settings for that part. For the detail behind the pins, see Pin naming; for the wires between them, Wires and chains.
Going deeper
- The classes are generated at build time from the catalogue and the component registry, which is why
from wiring import *stays in step with the shop without anyone editing the library. - Every part is a
Componentwith aTYPE(its slug). Subclassing it with aTYPEthat is not in the catalogue raises aCircuitError; for your own reusable parts, subclass Module instead. - The bill is part of the score. A build over the task's budget cannot be submitted, so a cheaper wiring (or a kit) can matter as much as a faster program.
Partis the escape hatch for slugs that have not been given a friendly class name yet, and for building parts from a list in a loop.