Project 4: Touch-Controlled LED
Control LED with a Touch Sensor
10/23/20265 min read
Introduction
Have you ever used a touch-sensitive lamp or a screen that responds to your finger? Touch sensors allow electronic devices to detect when someone touches a surface without needing a traditional mechanical button.
In this project, you will use a TTP223 touch sensor module and an Arduino Uno to control the board's built-in LED. When you touch the sensor, the LED will turn on. When you remove your finger, the LED will turn off.
This project introduces you to touch sensing and shows how Arduino can respond to signals from a sensor.
What You Will Learn:
How a touch sensor detects touch.
How to connect a TTP223 module to an Arduino Uno.
How to read a digital signal using digitalRead().
How to use if and else statements.
How sensors can control electronic components.
How touch-sensitive controls are used in everyday devices.
1. Components Required
You will need the following components from your Arduino robotics kit:
1 Arduino Uno
1 TTP223 touch sensor module
Jumper wires
1 USB cable to connect and power the Arduino
This project uses the built-in LED on the Arduino Uno, so you do not need an external LED or an additional resistor.
2. Understanding the TTP223 Touch Sensor
The TTP223 is a touch sensor module that detects when a finger touches its sensing surface.
Unlike a traditional push button, it has no moving mechanical parts. Instead, it detects changes in capacitance caused by your finger touching the sensor area.
Touch sensors like this are commonly used in:
Touch-sensitive lamps
Electronic switches
Control panels
Interactive toys
Home automation devices
Robotics projects
The TTP223 module provides a digital output signal that an Arduino can read.
For the standard active-HIGH, momentary configuration used in this project:
When the sensor is touched: The OUT pin goes HIGH.
When the sensor is not touched: The OUT pin goes LOW.
Your Arduino reads this signal and uses it to control the built-in LED.
[Add an image highlighting the touch-sensitive area and the OUT, VCC, and GND pins on the TTP223 module here]
3. Connecting the Touch Sensor to Arduino
Let's connect the TTP223 module to your Arduino Uno.
Step 1: Identify the Sensor Pins
Look at your touch sensor module and identify its three main connections:
OUT or SIG: Sends the sensor's digital signal to the Arduino.
VCC: Supplies power to the module.
GND: Connects to the Arduino's ground.
The exact labels may vary depending on your module.
Step 2: Connect the Signal Pin
Connect the sensor's OUT or SIG pin to Arduino digital pin 2.
This allows the Arduino to read the sensor's output.
Step 3: Connect the Power Pin
Connect the sensor's VCC pin to the supply voltage specified for your particular module.
Check the module's documentation or markings before choosing between 3.3V and 5V.
Step 4: Connect Ground
Connect the sensor's GND pin to an Arduino GND pin.
Your connections should be:
Touch sensor OUT/SIG → Arduino digital pin 2
Touch sensor VCC → Arduino supply voltage supported by the module
Touch sensor GND → Arduino GND
The built-in LED does not require any additional wiring.


4. Writing the Arduino Code
Now let's program the Arduino to respond to your touch.
Open the Arduino IDE using the setup you completed in Project 1.
Copy and paste the following code into your sketch:
Upload the code to your Arduino Uno.
Once the program starts running, touch the TTP223 sensor's sensing surface and observe the built-in LED.
When you touch the sensor, the LED should turn on.
When you remove your finger, the LED should turn off.
This behavior assumes your module is configured for momentary, active-HIGH output.
[video demonstration showing the built-in LED responding to touch here]
5. Understanding the Code
Let's break the program into simple parts so you can understand how it works.
A. Defining the Sensor Pin
This line assigns the name TOUCH_PIN to Arduino digital pin 2.
The Arduino will use this pin to receive the signal from the touch sensor.
Using a descriptive name makes the code easier to read and understand.
B. Defining the LED Pin
LED_BUILTIN is a predefined constant that represents the built-in LED pin on the Arduino board.
On a standard Arduino Uno, this is digital pin 13.
Using LED_BUILTIN means you do not need to connect an external LED to the breadboard.
C. Setting Up the Pins
The setup() function runs once when the Arduino starts or resets.
Inside this function:
pinMode(TOUCH_PIN, INPUT) configures pin 2 to receive the touch sensor's digital signal.
pinMode(LED_PIN, OUTPUT) configures the built-in LED pin so the Arduino can control it.
The touch sensor produces its own output signal, so we use INPUT rather than OUTPUT for its pin.
D. Reading the Touch Sensor
The digitalRead() function checks whether the sensor's output is HIGH or LOW.
The result is stored in the variable touchState.
For the sensor configuration used in this project:
HIGH means the sensor has detected a touch.
LOW means the sensor has not detected a touch.
The Arduino repeats this reading continuously while the program is running.
E. Using an IF Statement
The if statement checks whether the touch sensor's output is HIGH.
If the condition is true, the Arduino turns on the built-in LED using digitalWrite().
The double equals sign == checks whether two values are equal.
F. Using an ELSE Statement
The else statement runs when the condition in the if statement is false.
When the sensor output is LOW, the Arduino turns off the built-in LED.
Together, the if and else statements make the LED follow the sensor's output.
G. Repeating the Process
The loop() function runs repeatedly while the Arduino is powered.
The Arduino continuously checks the sensor's output and updates the LED.
This allows the LED to respond to your touch without needing to restart the program or press a separate button.
6. Real-World Applications
Touch sensors are used in many modern electronic devices because they allow people to interact with technology without traditional mechanical switches.
Here are a few examples:
Touch-Sensitive Lighting: A touch sensor can be used to control a lamp or other lighting system.
Interactive Toys: A toy can respond when someone touches a particular area, triggering lights or sounds.
Home Automation: Touch sensors can act as control inputs for compatible lighting and automation systems.
Robotics: A touch sensor can provide input to a robot, allowing it to react when someone touches a designated part of its body.
In each example, the sensor detects an action and sends a signal to a controller, which decides what should happen next.
Congratulations! You have built a touch-controlled LED system using your Arduino Uno and a TTP223 touch sensor.
Through this project, you learned how to:
Connect a touch sensor module to an Arduino.
Read a digital signal using digitalRead().
Understand HIGH and LOW sensor states.
Use if and else statements to control an output.
Make an LED respond to touch.
Understand how touch sensors are used in real-world electronics.
These concepts will help you as you move toward more advanced robotics projects involving sensors, buttons, buzzers, and other electronic components.
CONTACT US
WhatsApp: +92 313 8444618
WhatsApp: +92 310 4166 312
Shipping worldwide from Lahore, Pakistan
Copyright © 2026 BrixBotics - All rights reserved.
Real hardware engineering for young minds.


