Watch your microcontroller work

A hands-on guide to the XIAO RP2040 (the chip on the QPAD) for the HTMAA embedded programming group assignment. You'll upload tiny programs, then use a multimeter and an oscilloscope to see what the pins are actually doing.

The board

A microcontroller pin is a wire whose voltage your code can set or read. The XIAO has 14 of them around its edge. The colored labels tell you which names a pin goes by and what extra jobs it can do.

Seeed XIAO RP2040 pinout. Left side top to bottom: D0/A0/P26, D1/A1/P27, D2/A2/P28, D3/A3/P29, D4/SDA/P6, D5/SCL/P7, D6/TX/P0. Right side: 5V, GND, 3V3, D10/MOSI/P3, D9/MISO/P4, D8/SCK/P2, D7/CSn/RX/P1.

On the front there are two small buttons: B (boot, hold it while plugging in USB to load new firmware) and R (reset, restarts your program). The pads on the back (SWDIO, SWCLK) are for advanced debugging; ignore them for now.

One pin can have several jobs, but only one at a time. If the QPAD's screen is using D4 and D5 for I2C, don't also use them to blink.

Words you'll hear

Electronics is full of acronyms. These are the ones that show up this week, in plain terms.

Power

GND
Ground, 0 V. The reference point every voltage is measured from. The black probe always goes here.
3V3
3.3 V, made on the board from USB power. It's what the chip runs on, what "HIGH" means, and the most any pin can safely take.
5V
Straight from USB. Useful for powering motors or LED strips. Never connect it to a D pin.
VCC
A generic name for "the power input" on a module. The QPAD's OLED has a VCC pin.

Signals

GPIO
General purpose input/output. A pin your code can either set (output) or read (input).
Digital
Only two states: HIGH (3.3 V, 1, true) or LOW (0 V, 0, false). Think of it as a bool.
Analog
Any voltage in between, like 1.27 V. Think of it as a float.
ADC
Analog-to-digital converter. The part of the chip that turns a voltage on A0–A3 into a number your code can use.In Arduino, analogRead gives 0–1023. In MicroPython, read_u16 gives 0–65535.
PWM
Pulse width modulation. The chip can't output 1.27 V, so it fakes it: it switches the pin on and off very fast, and things like LEDs and motors average it out.
Duty cycle
The share of time a PWM signal is on. 25% duty on a 3.3 V pin averages to about 0.8 V.
Pull-up
A resistor connecting a pin to 3.3 V, so it reads HIGH when nothing else is touching it. Buttons need one. The chip has built-in pull-ups you turn on in code.
Floating
A pin connected to nothing. It reads random values because it picks up noise. Pull-ups fix this.

Chips talking to chips

I2C / IIC
Inter-integrated circuit, pronounced "I squared C". Two wires that let one board talk to many chips, each with its own address. The QPAD's screen uses it.SDA carries the data, SCL carries the clock (the tick that says "read the next bit now").
UART / serial
Sends bytes one bit at a time with no clock wire. Both sides agree on a speed beforehand.TX transmits, RX receives. Baud rate is the speed in bits per second, like 115200.
SPI
Serial peripheral interface. Faster than I2C, uses four wires.SCK clock, MOSI data from the XIAO out, MISO data back in, CSn "chip select" (the n means it's active when LOW).
OLED
The small screen on the QPAD. It receives pixels from the XIAO over I2C.

Code

RP2040
The chip itself, made by Raspberry Pi. The XIAO is a tiny board by Seeed that carries the chip plus USB and power parts.
Arduino
A way of programming in C++. You write a setup() that runs once and a loop() that repeats forever, then click Upload. A program is called a sketch.
MicroPython
Python running directly on the chip. No compiling: you edit in an app like Thonny and press Run. It uses the P numbers for pins.
Serial Monitor
A window in the Arduino IDE (or the Shell in Thonny) that shows whatever your program prints. Your best friend for debugging.

Tools

Multimeter
Shows one number: voltage (V), resistance (Ω), or a beep for "connected" (continuity). Updates a few times a second.
Oscilloscope
Draws voltage over time, fast enough to see millionths of a second. "Scope" for short.
V/div, time/div
How much one grid square is worth, up and across. The two big knobs on the scope.
Trigger
Tells the scope when to start drawing, like "when the signal crosses 1.6 V going up", so the picture holds still.

Bools and floats on a wire

Everything you do with a pin falls into one of four kinds. The first two set a pin; the last two read one.

Bool out: digitalWrite

Sets the pin to 3.3 V or 0 V. Turns on LEDs, buzzers, relays.

Meter: 3.3 V or 0 V. Scope: a flat line that jumps.

Fake float out: analogWrite (PWM)

Switches on and off very fast. Dims LEDs, sets motor speed.

Meter: the average, like 0.8 V. Scope: full-height pulses of varying width.

Bool in: digitalRead

Reads whether the pin is HIGH or LOW. Buttons, switches, touch.

Meter: 3.3 V, dropping to 0 V when pressed.

Float in: analogRead

Measures any voltage between 0 and 3.3 V. Knobs, light sensors. Only A0–A3.

Meter and your code agree on the voltage.

There's a fifth kind you'll see on the QPAD: bytes. I2C, UART and SPI send numbers and text as fast streams of bits. You don't need to decode them this week; just recognize them on the scope as bursts of pulses.

The two tools

Multimeter

  1. Black probe in the COM jack, red probe in the VΩmA jack.
  2. Turn the dial to DC volts: a V with a straight line above it.
  3. Touch the black probe to GND and keep it there.
  4. Touch the red probe to the pin you want to measure and read the number.

For checking solder joints, unplug the board and use the beep setting: touch two points, and a beep means they're connected.

Oscilloscope

  1. Set the switch on the probe to 10x, and set the channel's probe setting on the scope to 10x too. If they don't match, every number is off by ten.
  2. Clip the little ground clip onto GND. Hook the probe tip onto your pin.
  3. Set the vertical knob to 1 V/div, so the 3.3 V signal is just over three squares tall.
  4. Set the horizontal knob (time/div) to the value each experiment gives.
  5. In the trigger menu choose Edge, Rising, and turn the level to about 1.6 V. The picture stops sliding.
  6. Optional: press Measure to show frequency and voltage, or Single to freeze one capture.

Five experiments

Pick an experiment. The board shows where each probe goes, the meter and scope show what you should see, and the steps below give the code. Uploading new code replaces whatever was on the board, so reflash the QPAD example afterward.

USB Multimeter, DC volts Oscilloscope 3.3V 0V

Don't break things