
Let's build the clicker.
Follow the steps in order. Start with one key on the breadboard. Only solder the final device after the tests work.
1 Gather these parts








See optional parts (RGB, OLED, case and soldering tools)




2 Program the RP2040
Use a MacBook Air, a USB-C data cable, and the Waveshare RP2040-Zero.
- On the Mac, open Apple menu → About This Mac. Note whether it says Intel or Apple M1.
- Install Thonny (the correct macOS version for the Mac).
- Download the Waveshare RP2040-Zero CircuitPython
.uf2file from circuitpython.org. - Hold the RP2040's BOOT button while plugging in USB. Release BOOT. Finder should show
RPI-RP2. - Drag the downloaded
.uf2ontoRPI-RP2. After reboot, Finder should showCIRCUITPY. - In Thonny, choose the CircuitPython (generic) interpreter if needed. Create the program below and save it to
CIRCUITPY/code.py.
import time
print("Hello from the clicker!")
while True:
print("Still running...")
time.sleep(1)CIRCUITPY doesn't appear, check the cable is a data cable and try BOOT again.3 Wire ONE magnetic sensor
Unplug USB first. This poster shows the actual RP2040-Zero pad order, a recognizable switch with its sensor underneath, and the three sensor wires.
| 49E sensor lead | Connect to RP2040 | Meaning |
|---|---|---|
| 1 — VCC | 3V3 (red rail) | Sensor power, 3.3 volts |
| 2 — GND | GND (ground rail) | Return / ground |
| 3 — VOUT | GP26 | Analog reading for Key 1 |
- With USB unplugged, connect RP2040
3V3andGNDto separate breadboard rails. - Place the sensor so its three leads occupy separate, unconnected rows. Identify pins with the flat front facing you, only after the teacher confirms your sensor's marking and datasheet.
- Connect VCC → 3V3, GND → GND, VOUT →
GP26. Optionally place a 0.1 µF capacitor between VCC and GND, near the sensor. - Teacher checks for a short between 3V3 and GND with the multimeter before reconnecting USB.
4 Watch the magnet move
Save this program over CIRCUITPY/code.py, then open the serial output in Thonny.
import time
import board
import analogio
sensor = analogio.AnalogIn(board.GP26)
while True:
print("Key 1 reading:", sensor.value)
time.sleep(0.1)- With the switch sitting securely above the sensor, write down the reading when it is not pressed.
- Press fully and write down the new reading. It may go up or down depending on magnet polarity and sensor orientation.
- Repeat a few times. If the values hardly change, reposition the sensor and switch; disconnect USB before changing wiring.
Key 1 — released __________ · pressed __________ · sensor marking __________
If the sensor output stays pinned close to 0 or maximum, stop and inspect wiring and orientation.
5 Add Keys 2 and 3
Unplug USB. Add two more Hall sensors. All three share the 3V3 and GND rails, but each sensor gets its own analog signal wire.
| Key | VCC | GND | VOUT |
|---|---|---|---|
| 1 | 3V3 | GND | GP26 |
| 2 | 3V3 | GND | GP27 |
| 3 | 3V3 | GND | GP28 |
import time, board, analogio
sensors = [analogio.AnalogIn(p) for p in
(board.GP26, board.GP27, board.GP28)]
while True:
print([s.value for s in sensors])
time.sleep(0.1)| Released | Fully pressed | |
|---|---|---|
| Key 1 | __________ | __________ |
| Key 2 | __________ | __________ |
| Key 3 | __________ | __________ |
6 Turn it into a USB keyboard
Download the CircuitPython library bundle matching your installed CircuitPython major version. Copy the adafruit_hid folder into CIRCUITPY/lib/ (create lib if missing).
Enter your six measured values into the RELEASED and PRESSED lists below. This code works whether your sensor readings increase or decrease when pressed.
import time, board, analogio, usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
sensors = [analogio.AnalogIn(p) for p in
(board.GP26, board.GP27, board.GP28)]
keys = [Keycode.Z, Keycode.X, Keycode.C]
keyboard = Keyboard(usb_hid.devices)
# REPLACE these examples with YOUR six readings.
RELEASED = [30000, 30000, 30000]
PRESSED = [45000, 45000, 45000]
held = [False, False, False]
while True:
for i, sensor in enumerate(sensors):
span = PRESSED[i] - RELEASED[i]
if abs(span) < 1000:
continue # Reposition/calibrate this sensor.
travel = (sensor.value - RELEASED[i]) / span
if not held[i] and travel >= 0.55:
keyboard.press(keys[i])
held[i] = True
elif held[i] and travel <= 0.35:
keyboard.release(keys[i])
held[i] = False
time.sleep(0.005)Save as CIRCUITPY/code.py. Open a blank text editor and test one key at a time. Expected keys: Z, X, C. If a key appears held down, unplug USB and check your calibration values.
7 Build the printed case
No custom PCB is required. The final enclosure must hold the Hall sensors still relative to the switches, and it should leave enough space for protected solder joints.
Optional: lights and display
Complete the three-key test first. These are short experiments using parts you already bought.
Built-in RGB LED · easiest
No extra wires. The board already has one programmable LED on GP16. Copy the matching neopixel.mpy library to CIRCUITPY/lib/.
import board, neopixel
light = neopixel.NeoPixel(board.GP16, 1,
brightness=0.10)
light[0] = (0, 90, 255)0.96" OLED display
Once the module's labeling is checked, connect VCC→3V3, GND→GND, SDA→GP4, SCL→GP5. Then run an SSD1306 CircuitPython example. Use it for a click counter or animated face.
WS2812B seven-pixel ring
Power and logic levels must be verified before connecting. For a 5V-powered ring, use a suitable 3.3V-to-5V LED data shifter; the purchased TXS0108E/TXB0108 boards are not automatically validated for WS2812B signals. See NeoPixel wiring guidance.
Future knob
Possible later, using an encoder module and spare GPIO pins. We are not adding this to the first breadboard test.
Help & teacher checks
My Mac does not show CIRCUITPY.
Use a USB cable that supports data; enter BOOT mode again; check Finder; flash the correct Waveshare RP2040-Zero .uf2.
The sensor reading does not change.
Unplug USB and check pinout, 3.3V and ground, each lead on an independent row, switch magnet position, and sensor orientation. A 49E output normally sits near the middle of the 3.3V supply away from magnets, but it is not guaranteed to travel the whole 0–65535 scale.
The keyboard types continuously.
Unplug USB. Check that RELEASED and PRESSED are not reversed accidentally and that all three keys return near their released readings. Recalibrate. Do not test keyboard HID code inside sensitive forms.
What must the teacher prepare?
If the RP2040-Zero boards arrive without headers, solder a suitable header/wire adapter so the board can connect to the breadboard. Confirm the exact sensor marking/datasheet and pin order. Check for shorts with a multimeter. Have the correct CircuitPython and library bundle ready on the Macs before class.
Waveshare pinout · SS49E reference datasheet · H3M3 magnetic macropad · Analog WASD firmware