Arduino Touch-Activated LED Project

This article showcases a beginner-friendly project that utilizes Arduino and touch-sensitive technology to control LED lights. The project involves building a simple circuit and programming the Arduino board to detect and respond to touch inputs. The LEDs light up in response to a conductive object, such as a finger, making contact with the circuit. This project is a fun and interactive way to learn the fundamentals of electronics and programming with Arduino.

About Touch-Activated LED Circuit Project

Similar to some of our previous projects, a two-colour LED module will be used in this project. However, rather than being sound-activated or flame-activated, a unique touch-activated sensor will be featured. In conjunction with an Arduino, the HW-494 metal touch sensor module will be a crucial component of this project in triggering a change of LED colour from red to green upon contact with the sensor.

This sensor is quite distinct in the fact that a change of state is not detected by a push of a button or the presence of a flame but instead, by human contact with the sensor.

The HW-494 sensor module is built with a specialized transistor as the main switch with metal wiring on its surface. When powering on the sensor module, a signal is continuously emitted at the front head of the transistor and when a conductive object is in contact with the transistor, the contacted object will provide some resistance, which in turn is detected by the sensor module.

Due to the conductivity of the human body and its resistance to electrical current, the transistor essentially switches to a HIGH state upon a physical touch, which is detected by the metal wiring around the transistor. Thus, this means that the switch can be triggered by any metallic/conductive object or just a human touch.

Components for Touch LED Projects

Upon closer inspection of the module, you may also see that there is an amplifier circuit built into the module. The main purpose of this circuitry is to amplify any minuscule changes in the resistance of the emitted signal, resulting in even the slightest touch to the sensor activating it.

Furthermore, there is an additional potentiometer on the module PCB so if your sensor is not detecting a touch properly, you will likely need to calibrate the sensitivity by rotating the potentiometer clockwise (to increase sensitivity) or counterclockwise (to decrease sensitivity). 

In terms of the code associated with this project, there certainly are similar concepts that you may have come across from previous projects as the metal sensor module is basically a digital input device with the LED module as the output device. As a result, the code will feature functions and statements that have previously been used and that you may already be familiar with. Expanding the scope of this project is another aspect that you should consider as similar to some of our previous projects, adding in these sensors to your existing projects should not be an issue after you have understood the basic concepts.

From creating model traffic light systems to using this sensor for user input in a home automation system, the versatility of this sensor is like any other input switch device, but the main advantage of the HW-494 is how sensitive and responsive it is to even the slightest or continuous touch. In regards to the components needed for this project, they are as follows:

  • Arduino Nano (other Arduino-compatible boards will work)
  • USB cable (compatible with the Arduino board)
  • Breadboard
  • Male-Male Jumper Wires (6)
  • HW-494 Metal Touch Sensor Module
  • HW-480 Red/Green 2-Colour LED Module (common cathode)
  • 220Ω resistors (2)

Touch LED Wiring Circuit Diagram

Depending on your Arduino board, you may or may not require a breadboard to plug your board in. In this example, an Arduino Nano is used, thus requiring a breadboard but if you are using an Arduino Uno, for example, the jumper wires can be plugged in from the components on the breadboard directly to the board pins.

The wiring for this project is fairly simple as aside from the main modules, not a lot of extra components are needed. In terms of the metal touch sensor module, the HW-494 sensor module that is featured in this project has a 4-pin configuration where there is a digital output (DO) and analogue output (AO). If your module has this same 4-pin configuration, use the digital output (DO) but if your module has a 3-pin configuration, the standard output/signal pin will work.

In terms of the LED module, the reason that two 220Ω resistors are connected in series with the two outputs from this module is to prevent the LEDs from burning out when applying a supply voltage of +5 volts. A circuit diagram of the wiring is also featured below.

HW-494 Metal Touch Sensor Module: Connect the digital output (DO)/signal pin to D4 on your Arduino board, the positive (+) pin to +5v and the GND (G) pin to GND.

HW-480 Red/Green 2-Colour LED Module: Insert one 220Ω resistor in the breadboard in series with the output pin for the red colour LED signal (R) and insert another 220Ω resistor in series with the output pin for the green colour LED signal (G). Connect the red colour output pin (R) to D2 and the green colour output pin (G) to D3. Connect the negative (-) pin to GND on your Arduino.

Now, you can plug in your Arduino board via the USB cable to the computer.

Arduino Touch LED Electronics Project

Touch-Activated LED Project Code

					int redPin = 2;
int greenPin = 3;
int sensorPin = 4;
boolean val = 0;
void setup(){
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(sensorPin, INPUT);
void loop (){
val = digitalRead(sensorPin);
if (val == HIGH) {
  digitalWrite(greenPin, HIGH);
  digitalWrite(redPin, LOW);
else {
  digitalWrite(redPin, HIGH);
  digitalWrite(greenPin, LOW);

Explanation of the Code

To start with, the first section is where all the pins of the input and output devices are defined, which includes the two pins (red and green signal) from the HW-480 2-Colour LED module and the signal pin from the HW-494 metal touch sensor module. This should be familiar as seen by the codes of many previous projects. A boolean variable called ‘val’ is additionally defined and is set to 0 (LOW) at the start, as it will be used to store the output that comes from the HW-494 sensor module. If you are unfamiliar with a boolean data type, it is unique in the fact that it can only store either a true or false value (HIGH or LOW), making it ideal for an application like this.

Moving onto the void setup section, we now declare the two-colour LED module pins as outputs since signals are going to be sent to the module from the Arduino. Contrastingtly, the metal touch sensor pin is set as an input device as the physical touch of the sensor is what is going to activate it, resulting in a HIGH signal being sent to the Arduino for processing. The serial communication baud rate (9600 bauds) is also defined in this section for debugging purposes. If your HW-494 sensor module is not responding to a touch, you may have to calibrate its sensitivity and using the serial data coming in will greatly help in this process.

Regarding the void loop section, the previously-defined boolean variable is now set to the digital value which the HW-494 sensor module is outputting to the Arduino (via the digitalRead function). For example, upon a touch of the sensor, a HIGH signal will be sent from the module to the Arduino and resultantly change the boolean variable value to 1. This value is also printed to the serial monitor.

Subsequently, an if else statement is now introduced which basically states that when the sensor is activated/touched, the LED module will display a green colour but whenever the sensor is not being activated (default state), the LED will be a red colour. The digitalWrite() function is used here to send a digital signal to the output device (LED module).


Now that this project is fully built and the code has been explained, there are many directions in which you can move this project forward. One common example is using the HW-494 metal touch sensor for automated systems as it could serve as replacements for traditional tactile switches. In addition, due to its high sensitivity, it could be used for projects that require rapid response times and minimal human error. A major hope of TechSparks Arduino projects is that after familiarizing yourself with the hardware used and some of the coding principles, we hope that you could apply your newfound knowledge to other, much larger projects. By manipulating certain lines of the code, or by wiring additional components, a basic project like this can be upgraded to something that serves a greater practical use, such as a tally counter.

You Might Be Interested​

How to Enable Multi-Core on ESP32 Microcontroller
How to Enable Multi-Core on ESP32 Microcontroller

This comprehensive guide elucidates the process of enabling multi-core functionality on the ESP32 microcontroller, leveraging its dual-core architecture for enhanced parallel processing capabilities. Through detailed

Arduino MQ-3 Alcohol Sensor Project
Arduino MQ-3 Alcohol Sensor Project

Creating an alcohol sensing project with an MQ-3 sensor and Arduino allows for accurate alcohol concentration monitoring in environments like bars and factories. The MQ-3

Arduino Temperature Alarm Project
Arduino Temperature Alarm Project

This Arduino temperature alarm project effectively demonstrates how to create a practical temperature monitoring system. By utilizing the LM35 temperature sensor and a buzzer, it

Arduino Breathing LED Project
Arduino Breathing LED Project

A breathing light is an LED lighting effect that simulates the human breathing process, gradually increasing or decreasing in brightness within a specific cycle. This

Scroll to Top