Anu Electronics TTP223 touch sensor tutorial cover showing red touch modules and Arduino circuit, wiring and code title.

TTP223 Touch Sensor with Arduino Uno: Circuit, Wiring and Code

EDITOR REVIEW — TECHNICAL CHECK PENDING: Confirm the supplied module revision, header fit and active-high/direct output before publication. The store photo shows a 223B chip and unpopulated header holes, but the listing does not guarantee the shipping revision or total module current. Code is reviewed but has not been compiled or tested on hardware.

Turn a touch pad into an Arduino input with the TTP223 touch module. Touch the pad to light the Uno’s built-in L LED and display a message in Serial Monitor. Release it to switch the LED off. This project introduces digital inputs without a mechanical button.

Level: beginner after header assembly. Time: about 20 minutes. What you will build: a USB-powered touch indicator with three signal/power connections.

Contents

  1. How it works
  2. Parts and tools
  3. Pinout and connections
  4. Assembly and IDE setup
  5. Complete program
  6. Upload and test
  7. Troubleshooting and FAQs

How it works

The module senses a change in capacitance at its touch electrode and converts it to a digital output. The Uno reads that output on D2. In active-high direct mode, a touch produces HIGH and release produces LOW. The program mirrors this state on LED_BUILTIN.

Tontek’s TTP223-BA6 documentation identifies the photo’s 223B marking and supports selectable output polarity and direct/toggle modes. Those chip options do not establish which PCB pad is A or B on every module. Leave solder pads unchanged for the first test and check observed behavior. In toggle mode, the output stays in its new state after release.

Parts and tools

Component / purchase link Required Specification / pack size
TTP223 touch module 1 Store lists 2–5 V; use 5 V with Uno R3.
Arduino Uno R3 1 Classic 5 V board; uses its built-in L LED.
Male-to-female jumper wires 3 leads 20 cm; sold in a pack of 40.
USB A–B data cable 1 Fits the Uno R3 Type-B socket.
Breakaway male header One 3-pin section, if needed 2.54 mm pitch; pack contains ten 40-pin strips. Check the module hole spacing before fitting.

A computer with Arduino IDE is required. If the module arrives without its header soldered, also use a soldering iron, solder and suitable eye protection, or ask for assembly help. No breadboard or external LED/resistor is needed for the direct wiring shown.

Pinout and connections

Module label Uno pin Role / wire colour
VCC 5V Power / orange
GND GND Common ground / grey
I/O (OUT) D2 Module output to Arduino input / teal

The I/O label on this module is its digital output; do not configure Arduino D2 as an output. Always follow the board’s printed labels. The diagrams use symbolic board outlines rather than physical header locations.

Circuit schematic

TTP223 module schematic: Uno 5V to VCC, GND to GND and D2 to I/O.
TTP223 module schematic: Uno 5V to VCC, GND to GND and D2 to I/O.

Visual module wiring

Symbolic three-wire TTP223 to Arduino Uno connection guide.
Symbolic three-wire TTP223 to Arduino Uno connection guide.

Assembly and IDE setup

  1. Disconnect USB. Inspect the module labels, header holes and solder pads. If needed, fit a three-pin male header, solder all three joints and check for bridges. Do not rely on loose pins pushed into unsoldered holes.
  2. With power still removed, connect the female ends of three jumper leads to the module header. Connect their male ends to Uno 5V, GND and D2 as listed above.
  3. Place the module on a dry, nonconductive surface. Keep loose metal away from the board and leave the touch electrode accessible.
  4. Install Arduino IDE from Arduino’s official software page. Select Arduino Uno under Arduino AVR Boards and choose the connected port.
  5. Paste the complete sketch below. No extra library, cloud service or account is required.

Power notes: use the Uno’s USB supply for this build. Do not use VIN, mains wiring or an external higher-voltage supply for the sensor. A 5 V module output must not be connected directly to a 3.3 V-only GPIO. The chip’s microamp standby specification excludes the module’s LED and other loads; total board current is not specified by the store. Power the module from the supply pin, never a GPIO, and use its output only as a logic signal.

Complete program

Download the complete Arduino code (.txt). Save the contents as ttp223_touch.ino in a matching sketch folder.

// TTP223 module: VCC -> Uno 5V, GND -> GND, I/O -> D2.
// For classic 5V Uno R3 and a direct-mode module.
const byte TOUCH_PIN = 2;
const bool ACTIVE_HIGH = true;
int previousRaw = -1;

void setup() {
  pinMode(TOUCH_PIN, INPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
  Serial.begin(9600);
  Serial.println("Keep the pad clear during startup.");
  delay(1000);
}

void loop() {
  int raw = digitalRead(TOUCH_PIN);
  bool touched = ACTIVE_HIGH ? (raw == HIGH) : (raw == LOW);
  digitalWrite(LED_BUILTIN, touched ? HIGH : LOW);
  if (raw != previousRaw) {
    Serial.print("OUT=");
    Serial.print(raw);
    Serial.println(touched ? "  TOUCH" : "  RELEASE");
    previousRaw = raw;
  }
  delay(10);
}

What the code does

INPUT lets D2 read the module’s driven output without enabling a pull-up. ACTIVE_HIGH selects the interpretation of that output. The one-second startup pause gives the sensor time to settle while the pad is clear. previousRaw limits serial messages to state changes, including the first reading. The 10 ms loop pause is a polling interval, not a guarantee of sensor response time.

Upload and test

  1. Click Verify, then Upload. Open Serial Monitor at 9600 baud.
  2. Reset the Uno and keep the pad untouched through startup. Allow at least a second before testing.
  3. In active-high direct mode, expect OUT=0 and RELEASE at rest. Touch for about one second: the built-in L LED should turn on and the text should become OUT=1 and TOUCH.
  4. Release the pad. The LED should turn off and RELEASE should appear. Repeat several times.
  5. If polarity is reversed, first confirm wiring and the module’s output mode. For an otherwise correct active-low direct module, set ACTIVE_HIGH to false and upload again.
Keep the pad clear during startup.
OUT=0  RELEASE
OUT=1  TOUCH
OUT=0  RELEASE

This is illustrative output, not a hardware measurement. Short taps may be missed because the sensor has its own response delay. If the module is in toggle mode, the messages describe the latched output rather than whether your finger is currently touching.

Illustrative animation of touch and release controlling the Uno built-in LED.
Illustrative animation of touch and release controlling the Uno built-in LED.

Troubleshooting

  • Always HIGH or LOW: verify VCC, GND and I/O labels, D2 selection, common ground and solder joints.
  • Output stays on after release: inspect the module’s mode documentation; it may be set to toggle. Do not guess which A/B pad to bridge.
  • False triggers: use short leads, a stable USB supply and a clean, dry pad. Move it away from metal, then power-cycle with the electrode clear.
  • No serial text: check port, cable, baud rate and reset the board after opening Serial Monitor.
  • LED action reversed: check the observed output polarity before changing ACTIVE_HIGH.

Frequently asked questions

Can the sensor drive a relay or motor directly?

No. This circuit reads a logic output. Loads need an appropriately rated driver and supply.

Can it sense through a plastic cover?

Capacitive sensing can work through a suitable nonconductive panel, but thickness and construction affect sensitivity. Test the intended enclosure; this tutorial does not promise a detection distance.

Is this a touch-position sensor?

No. It reports one digital key state, not finger position or pressure.

Related projects

Practice output wiring with our ESP32 LED blink tutorial or compare digital sensing with the Arduino voltage-divider tutorial. Use each project’s own board voltage and pin assignments.

Ready to build? Get the TTP223 touch module and compatible parts from the table above.

Technical sources and validation

Original tutorial, sketch and connection drawings. The cover uses the store product photo as its hardware reference. No physical test or compiled-code validation has been performed; shipping-module revision and total board current remain review items.