The TTP223B is a single-channel capacitive touch sensor IC used as a touch-button replacement. It provides a digital touch-detect output for direct connection to a microcontroller input and is commonly used in simple touch interfaces.
| Pin | Signal | Description |
|---|---|---|
SIG |
digital | Digital touch-detect output from TTP223B — connect to a microcontroller input |
VCC |
power | Positive supply input for the touch sensor module, typically 2.0–5.5V |
GND |
ground | Ground reference for the touch sensor module and output signal |
| From | To | Wire |
|---|---|---|
board:5V |
x1:VCC |
red |
board:GND |
x1:GND |
black |
board:D2 |
x1:SIG |
green |
This example was written and compile-checked for the arduino-uno. Codey Online adapts it to any other supported board for you.
const int touchPin = 2;
const int ledPin = 13;
void setup() {
pinMode(touchPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
while (!Serial) {
;
}
Serial.println("TTP223B touch sensor example");
}
void loop() {
int touchState = digitalRead(touchPin);
digitalWrite(ledPin, touchState);
Serial.print("Touch state: ");
if (touchState == HIGH) {
Serial.println("TOUCHED");
} else {
Serial.println("not touched");
}
delay(50);
}
Describe what you want to build. Codey Online writes the code, draws the wiring diagram, compiles it and flashes your board straight from the browser.
Start for free