I connected a TTP223 touch-sensor module to my XIAO RP2040 board and used its digital output to control the board’s LED. The module detects a change in capacitance when a finger approaches or touches the sensing area. The microcontroller receives an on/off signal; this program does not measure capacitance directly.
Our group used a multimeter and oscilloscope to observe an input device. The multimeter helps us compare voltage levels, while the oscilloscope shows how a signal changes over time. The shared sensor work uses an MQ135, which is separate from the TTP223 used in the individual exercise below.
Our setup and observations are on our group assignment page. We need to retain the probe connections, voltage scale and time scale with the observations so that the signal can be understood.
I soldered the module’s VCC to 3.3 V, GND to the board ground and signal output to D9. The existing LED is connected to D1. Sharing a ground reference lets the board interpret the sensor output correctly.
| Connection | Board pin or rail |
|---|---|
| TTP223 VCC | 3.3 V |
| TTP223 GND | GND |
| TTP223 signal | D9 |
| LED output | D1 |
I used a multimeter to check the sensor supply before running the program. The photographs show this check, but I have not transcribed a verified reading into the text. I then opened the sketch in the Arduino IDE and uploaded it to the board.
The sketch creates a touch object on D9. Each loop calls touch.update(), checks touch.isTouched() and sets D1 high or low. The original sketch depends on TouchSensorLib.h; its exact library source and version still need to be archived for a reproducible build.
#include <TouchSensorLib.h>
TouchSensor touch(D9); // D9 on XIAO
int ledPin = D1; // D1 on XIAO
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
touch.update(); // always call this first
if (touch.isTouched()) {
digitalWrite(ledPin, HIGH); // LED ON while touching
} else {
digitalWrite(ledPin, LOW); // LED OFF when not touching
}
}
The video records the touch-input test with the LED as visible feedback. Touching and releasing the sensor lets me compare an input change with an output response. It demonstrates detection rather than a calibrated measurement of force or contact area.
The main lesson was to describe what the sensor actually reports. A touch module can hide the capacitance processing inside its own circuit, leaving a simple digital interface for the microcontroller. Keeping that distinction clear makes both the wiring and the code easier to explain.
The download preserves the original sketch, including its library dependency.
I prepared a library-free version with Codex assistance, keeping D9 as the touch input and D1 as the LED output. It uses digitalRead(), waits for a stable state for 30 ms and logs TOUCHED or RELEASED at 115200 baud. It builds for the XIAO RP2040 with Arduino-Pico 4.5.3; it is not a recovered copy of TouchSensorLib.h.
The module's active level and momentary/toggle setting still matter. The new source makes the active level explicit, so I can adjust it to the actual TTP223 instead of treating every module configuration as identical. I will record supply and output levels, then touch and release several times while observing both the serial state and LED. I still need that physical retest and the actual board revision.