Assignment Tasks

πŸ”¬ Group Assignment

  • Probe an input device's analog levels and digital signals using a multimeter and an oscilloscope

πŸ‘€ Individual Assignment

  • Measure something β€” add a sensor to a microcontroller board that you have designed and read it

Introduction

For this week's assignment, I designed a custom PCB that incorporates a push button as an input device and an LED as a visual output indicator. The goal was to build a complete input–output system from scratch β€” designing the schematic and layout in KiCad, fabricating the board, soldering the components, and writing firmware that reads the button state and responds by toggling the LED.

This exercise builds directly on my earlier work in electronics design and production, allowing me to integrate input sensing into a self-designed board rather than relying on a development kit. It also pushes toward my final project, which involves a smart light fixture where user inputs control lighting behavior.

Components & Tools

Component / ToolDetails
MicrocontrollerSeeed XIAO ESP32-C3
Input deviceSMD tactile push button
Output indicatorThrough-hole LED
Design softwareKiCad
Programming IDEArduino IDE
Pin assignmentsButton β†’ D1, LED β†’ D9

Step-by-Step Documentation

1

Schematic Design in KiCad

I started by designing the circuit in KiCad. The design centers on the Seeed XIAO ESP32-C3, chosen for its compact footprint, built-in Wi-Fi/Bluetooth capabilities, and compatibility with the Arduino ecosystem. For this assignment I used only its GPIO functionality, but the wireless capability will be relevant for my final project.

The schematic includes:

  • A tactile SMD push button on pin D1.
  • A through-hole LED on pin D9, with a current-limiting resistor to prevent overcurrent damage to both the LED and the microcontroller.
MicrocontrollerXIAO ESP32-C3
Input PinD1
Output PinD9
KiCad schematic showing the ESP32-C3, SMD button on D1, and LED on D9
The ESP32-C3 Datasheet
KiCad schematic showing the ESP32-C3, SMD button on D1, and LED on D9
Schematic Design Diagram
2

Component Selection

I chose a through-hole LED for ease of soldering and visual clarity, and an SMD tactile button to practice working with surface-mount components.

The through-hole LED used as the output indicator
Through-hole LED β€” output indicator
SMD tactile push button β€” the primary input device
SMD tactile push button β€” primary input
3

PCB Layout & Fabrication

With the schematic complete, I moved to the PCB layout design phase in KiCad.

PCB layout showing component placement
PCB layout design β€” component placement
3D render of the board in KiCad before fabrication
Final fabricated PCB

Key layout decisions: button placed at the board edge for easy thumb access; 0.8 mm trace widths for signal lines; ground fill on the bottom copper layer to reduce noise and simplify routing.

4

Firmware β€” Arduino IDE

The firmware was written in the Arduino IDE, using the ESP32-C3's Arduino-compatible environment. The logic is simple: poll the button state continuously and mirror it to the LED.

// XIAO ESP32 C3 - LED and Button
const int LED_PIN    = 9;  // GPIO9
const int BUTTON_PIN = 3;  // GPIO3

void setup() {
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);  // Internal pull-up resistor
}

void loop() {
  int buttonState = digitalRead(BUTTON_PIN);

  // Button is LOW when pressed (due to INPUT_PULLUP)
  if (buttonState == LOW) {
    digitalWrite(LED_PIN, HIGH);  // Turn LED ON
  } else {
    digitalWrite(LED_PIN, LOW);   // Turn LED OFF
  }
}
}
Arduino IDE code, ready to upload
The complete sketch loaded in Arduino IDE, ready to upload
The complete sketch loaded in Arduino IDE screenshot
5

Testing & Results

After uploading the firmware, I tested the board by pressing and releasing the button repeatedly to confirm:

  1. The LED illuminates immediately when the button is pressed.
  2. The LED turns off cleanly when the button is released.
  3. No false triggers occur when the button is not pressed.
  4. Behaviour is consistent across multiple press cycles.

All four conditions were satisfied. The response felt instantaneous β€” confirming that the INPUT_PULLUP configuration and polling-based loop are sufficient for this interaction speed.

The completed board with the LED lit β€” button being held down
Completed board with LED lit, button held down

Demo Video

The following video demonstrates the board in operation: pressing the button illuminates the LED, releasing it turns the LED off.


Design Files & Source Code

FileDescriptionDownload
W09_Input_Button_LED_KiCAD.zip Full KiCad project (schematic, PCB, BOM, netlist) ⬇ Download
πŸ“

The Arduino firmware is fully reproduced in the Code section above. All KiCad design files are available for download above.


Reflection

This assignment made concrete something I had understood only theoretically: designing the schematic, laying out the PCB, fabricating it, soldering it, and then writing code that makes a physical LED respond to a physical button press gives a deeply satisfying sense of the whole system.

My final project is a smart light fixture where user inputs control lighting behaviour. The button-to-LED circuit built here is a simplified version of that user-input subsystem. This week consolidated the electronics design and production skills from Weeks 6 and 8 β€” I now feel capable of designing a board that integrates sensors, writing firmware that reads and reacts to them, and debugging the result systematically.

← W08 β€” Electronics Production All Assignments W10 β€” Output Devices β†’
🤖

AI Disclosure: Claude (Anthropic) was used as a writing tool to help proofread and structure the documentation on this page. All designs, fabrication, and technical decisions are my own.