
No. 7 • Digital
Touch Sensor (TTP223B)
ตรวจจับการสัมผัสแบบ capacitive touch
Component NameTouch Sensor
Part No. / ModelTTP223B
Interface TypeDigital
PinsVCC, I/O, GND
Note: บางรุ่นสามารถตั้งโหมด toggle/momentary ได้จากจุด solder pad
Wiring Example
ตัวอย่างการต่อวงจรกับ Arduino UNO
| Sensor Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| I/O | D2 |
| GND | GND |
Arduino IDE Code
// Touch Sensor (TTP223B)
// Board: Arduino UNO
// Read digital output from the sensor module.
const int SENSOR_PIN = 2;
void setup() {
Serial.begin(9600);
pinMode(SENSOR_PIN, INPUT);
}
void loop() {
int state = digitalRead(SENSOR_PIN);
Serial.print("Sensor state: ");
Serial.println(state);
delay(300);
}