Electronics Design

Let there be light

Following Alfonso's advice, I began with a simple push-button LED circuit to learn the basics instead of attempting a more complex project that I wouldn't be able to troubleshoot. Even this straightforward project kept me busy, primarily because I am learning to code and using KiCAD for the first time.

In retrospect, I wonder if there might be an even simpler entry point. I've come across conflicting information online and am still trying to understand how different components work together. However, starting with a simple project was definitely the right approach.and am still grasping what components are and how they work together. But starting simple was definitely the right approach.

Materials
- Xiao RP2040 $4.68
- LED $0.20
- Resistors (100Ω, and 10kΩ) $0.01 ea
- Push Button $0.92

Software
- KiCAD
- Wokwi

KiCad Schematic (.kicad_sch)


const int LED_PIN = 2;      
const int BUTTON_PIN = 3;   

void setup() {
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT);
}

void loop() {
 int buttonState = digitalRead(BUTTON_PIN);
  
  if (buttonState == LOW) {
    digitalWrite(LED_PIN, HIGH);
  } else {
    digitalWrite(LED_PIN, LOW);
  }
  
  delay(100);
}
        

Design Guide

A microcontroller (MCU) is a small computer integrated into a single chip. It has a processor, memory, and input/output pins all built into one package. It's like the "brain" that controls electronic devices.

Read These:

Your MCU's datasheet - Eventually all the pages.
Application notes from the manufacturer - These explain how to use specific features.
Reference designs - Manufacturers provide example circuits you can copy and learn from.

1. Understanding Your Needs

Before choosing any components, you need to define what your project will do. This guides every decision you make later.

Key Questions to Answer:

2. Choosing a Microcontroller

The microcontroller is the heart of your design. Understanding its specifications helps you pick the right one for your project.

Key Specifications:

3. Power Supply

Microcontrollers typically run on 3.3V or 5V. Your power supply converts whatever voltage you have (battery, USB, wall adapter) into the voltage your MCU needs.

Voltage Regulators

LDO (Low Drop-Out): Simple, cheap, but wastes energy as heat. Good for low current applications.

Switching Regulator: More efficient, complex, can handle higher currents. Better for battery projects.

Decoupling Capacitors

Think of these as tiny electrical "shock absorbers". They smooth out voltage bumps and noise.

    Small capacitor (0.1µF) right next to EACH power pin
    Larger capacitor (10µF) near the regulator
    Place them as close as possible to the MCU power pins!

4. Reset Circuit - The Restart Button

A reset circuit resets your microcontroller back to the beginning of your program. It's like pressing Ctrl+Alt+Delete on a computer.

Basic Design Components:

5. Programming Interface

This is how you upload code to your microcontroller. Different MCU families use different methods.

Common Types:

What You Need: Pin headers on your board so you can plug in the programmer. Follow the exact pinout for your MCU family and label the pins clearly!

6. Input/Output (I/O) Design

Digital Inputs (Reading Buttons, Switches)

When reading buttons or switches, you need a pull-up resistor (10kΩ) to keep the pin at HIGH when the button is not pressed. When the button is pressed, it connects to ground and the pin reads LOW. The resistor prevents a short circuit.

Digital Outputs (Controlling LEDs)

Use a current-limiting resistor for LEDs (typically 220Ω - 1kΩ). This prevents burning out the LED or MCU pin. Higher resistance creates a dimmer LED.

Analog Inputs (Reading Sensors)

Connect sensors to ADC (Analog-to-Digital Converter) pins. The MCU converts voltage (0-3.3V) to a number (0-4095 on a 12-bit ADC). Use a voltage divider if your sensor outputs higher voltage than the MCU can handle.

7. PCB Layout Basics

Ground Plane

Imagine a large copper sheet covering one entire layer of your circuit board. This is your ground reference and provides several benefits:

Component Placement Priority

Trace Width Guidelines

0.5mm minimum for main power (I used 0.6mm)

diagram