Week 05 / How to Make Almost Anything

Updated

Electronics
design

I designed a button and LED circuit around the XIAO RP2040, learnt the PCB design in KiCad, and tested the program in Wokwi. I also started the control-board schematic for my final project.

XIAO RP2040KiCad / FabLibWokwi
05 / ELECTRONICS DESIGNDigital 3D preview of the button and LED board in KiCad
The button and LED board in KiCad's 3D Viewer.
Individual assignment← Back to all weeks
Circuit designXIAO, button, and LED
PCB layoutRouting and rule checks
Program testButton input in Wokwi
01 / Parts and KiCad

Choosing parts and setting up KiCad

This was my first time using KiCad. I started with a small circuit: one button as an input and one red LED as an output.

I chose parts from the Fab Inventory and installed KiCad FabLib using the Fab Academy KiCad tutorial. The library includes schematic symbols and PCB footprints for parts used in the lab.

A symbol describes a part's electrical connections. A footprint describes its pads and physical layout on the board. FabLib helped me find matching parts, but it still needed to be checked due to 10% errors.

Parts selected for the button and LED board
Part and roleInventory partFabLib search
Microcontroller moduleSeeed Studio XIAO RP2040
102010428
Module_XIAO-RP2040
Tactile buttonPTS636 SM25F SMTR LFSSwitch_Tactile_CnK
Red LEDSML-LX1206IC-TRLED_1206
1 kΩ resistor for the LEDRC1206FR-071KLR_1206
Inventory entry for the 1 kΩ Yageo 1206 resistor
FIG. 01The 1 kΩ resistor in the inventory.
Inventory entry for the Lumex red 1206 LED
FIG. 02The red 1206 LED in the inventory.
Inventory entry for the Seeed Studio XIAO RP2040 module
FIG. 03The XIAO RP2040 controller in the inventory.
Inventory entry for the C and K PTS636 tactile switch
FIG. 04The tactile button in the inventory.

Installing the component library

I installed KiCad FabLib through the Plugin and Content Manager. Then I created a project with File → New Project. I used the .kicad_sch file for the schematic and the .kicad_pcb file for the board layout.

KiCad Plugin and Content Manager with KiCad FabLib installed
FIG. 05Installing KiCad FabLib through the Plugin and Content Manager.
02 / Schematic

Connecting the button and LED

I connected the LED to D0 through a 1 kΩ resistor, and the button between D10 and ground.

The resistor limits the current through the LED. The button changes the input state when pressed. In the program, I enabled the microcontroller's internal pull-up resistor, so the input is HIGH when the button is released and LOW when it connects to ground.

I added the parts from FabLib, drew the wires, and named the signals LED_CTRL and BTN. The schematic records the electrical connections before I decide where the parts will sit on the PCB.

KiCad schematic with a 1 kΩ resistor and LED on D0 and a button on D10 connected to ground
FIG. 06The schematic: D0 drives the LED through 1 kΩ; the button connects D10 to ground.

KiCad shortcuts I used

Shortcuts in the Schematic Editor
AAdd a symbol
MMove a symbol
RRotate a symbol
EEdit properties
WDraw a wire
LAdd a net label
PAdd a power symbol
EscEnd the current action

Checking the schematic with ERC

I ran the Electrical Rules Checker (ERC) after wiring the circuit.

The screenshot shows an error: "Input Power pin not driven by any Output Power pins."

ERC checks the schematic's rules. It does not run the microcontroller program or confirm how the physical circuit will behave.

KiCad Electrical Rules Checker reporting one input power pin without a power output driver
FIG. 07An ERC result: a power-input pin had no power-output driver.
03 / PCB layout

Placing components and routing the board

I transferred the schematic into the PCB Editor, arranged the footprints, and routed the connections.

I used Tools → Update PCB from Schematic, with the default shortcut F8. The footprints appeared with a ratsnest: thin lines showing connections that still needed copper tracks.

I drew a closed board outline on Edge.Cuts, then selected F.Cu to route the tracks on the front copper layer. The layout placed the XIAO module near the top, with the LED and resistor below it and the button to the right.

KiCad PCB Editor with XIAO RP2040, resistor, LED and button footprints before routing
FIG. 08The footprints after updating the PCB from the schematic.
KiCad PCB Editor showing a rectangular board outline and front copper tracks between the module, button, resistor and LED
FIG. 09The board outline and routed tracks on F.Cu.
04 / Design checks

Checking the layout

The DRC result showed 0 errors and 23 warnings. Most of the warnings concerned silkscreen text.

The Design Rules Checker (DRC) checks the PCB against configured constraints. My screenshot also showed 0 unconnected items, 0 schematic-parity issues, and 5 ignored tests.

The warnings included text clipped by the board edge, silkscreen clearance, and text that was too small.

KiCad Design Rules Checker showing 0 errors, 23 warnings, 0 unconnected items and 5 ignored tests
FIG. 10DRC: 0 errors, 23 warnings, and 5 ignored tests.

Viewing the board in 3D

I opened KiCad's 3D Viewer to check the connector orientation, component positions, and space around the parts. It helped me see how the layout would fit together as well as when soldering.

KiCad 3D Viewer rendering of the green board with a XIAO module, button, resistor, LED and mounting holes
FIG. 11The PCB in KiCad's 3D Viewer. This is a digital preview.
05 / Simulation

Testing in Wokwi

I rebuilt the circuit in Wokwi and ran the button-and-LED program on a simulated Raspberry Pi Pico.

KiCad's simulator uses ngspice for SPICE circuit simulation. It does not directly execute the Arduino program for this microcontroller circuit, so I used Wokwi for the test.

The Pico in Wokwi uses the same RP2040 microcontroller family as the XIAO, but the board labels are different. I matched the connections by RP2040 GPIO number.

Wokwi simulation of a Raspberry Pi Pico, pushbutton and LED, with serial messages showing the LED turning on when pressed and off when released
FIG. 12The Wokwi test with a Pico: button pressed, LED on; button released, LED off.

Matching the XIAO pins to the Pico

The Seeed Studio pin map shows that the XIAO's D10 pad connects to GPIO3, while D0 connects to GPIO26. In my Pico simulation, I therefore used BUTTON_PIN = 3 and LED_PIN = 26.

Pin mapping used in the Wokwi test
SignalXIAO padRP2040 GPIOPico program
Button inputD10GPIO3BUTTON_PIN = 3
LED outputD0GPIO26LED_PIN = 26
Seeed Studio XIAO RP2040 pin map showing D0 as GPIO26 and D10 as GPIO3
FIG. 13Seeed Studio's pin map. D10 is GPIO3, and D0 is GPIO26.

Button input and LED response

I set the button input to INPUT_PULLUP and the LED pin to OUTPUT. The program reads the button, treats LOW as a press, and turns the LED on while the button is held. It prints a message whenever the button state changes.

Core logic from the Pico simulation

const int BUTTON_PIN = 3;  // XIAO D10 corresponds to RP2040 GPIO3
const int LED_PIN = 26;    // XIAO D0 corresponds to RP2040 GPIO26

// In setup():
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT);

// In loop():
bool pressed = (digitalRead(BUTTON_PIN) == LOW);
digitalWrite(LED_PIN, pressed ? HIGH : LOW);

The serial monitor showed "BUTTON PRESSED | LED ON" and "BUTTON RELEASED | LED OFF" as I changed the input. This test confirmed the program's response in the simulation.

06 / Final project

Starting the control board

I also started the low-voltage control-board design for my final project.

The schematic combines a XIAO RP2040, a start button, and a connector for an OLED display. The display uses I2C, with separate SDA data and SCL clock signals. I also added an HV_CTRL connector for the control signals to a future high-voltage module.

This is the first version control-board schematic. I plan to design the high-voltage module separately to drive droplets. That module is the next part of the project.

KiCad schematic for the final project control board with XIAO RP2040, start button, I2C OLED connector and HV CTRL interface
FIG. 14The first control-board schematic for my final project.

Sources and credits

OpenAI Codex helped organize my notes, check technical references, polish the English, and improve the HTML layout.