🟦 1. Introduction
Touch sensors are modern input devices that detect human touch. In this project, we interface a capacitive touch sensor (TTP223) with Raspberry Pi to control an LED.
🟦 2. Components Required
- Raspberry Pi
- TTP223 Touch Sensor Module
- LED
- 220Ω Resistor
- Breadboard
- Jumper Wires
🟦 3. Circuit and Connections
| Raspberry Pi Pinout Diagram |
| TTP223 Touch Sensor Module Pinout Diagram |
- VCC → 3.3V (Pin 1)
- GND → GND (Pin 6)
- OUT → GPIO17 (Pin 11)
- LED + → GPIO18 (Pin 12)
- LED – → GND (via resistor)
🟦 4. Detailed Step-by-Step Working
- The touch sensor detects finger touch using capacitance.
- When touched, the OUT pin becomes HIGH.
- Raspberry Pi reads this signal through GPIO17.
- If HIGH → LED turns ON
- If not touched → LED OFF
🟦 5. Libraries to be Included
import RPi.GPIO as GPIO
import time
🟦 6. Python Program
import RPi.GPIO as GPIO
import time
sensor = 17
led = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(sensor, GPIO.IN)
GPIO.setup(led, GPIO.OUT)
while True:
if GPIO.input(sensor):
GPIO.output(led, True)
print("Touch Detected")
else:
GPIO.output(led, False)
time.sleep(0.1)
🟦 7. Output
- When you touch the sensor → LED turns ON
- When you release → LED turns OFF
🟦 8. Applications
- Touch-controlled lights
- Smart switches
- Home automation
- Security systems
🟦 9. Conclusion
Touch sensors provide a modern alternative to push buttons. This project helps beginners understand human-machine interaction using Raspberry Pi.