Last Updated or created 2025-10-27
Remember those expensive touch lights you can buy?

This is a less than 5 euro version.
Warning : Some tricks I used
- Using D5 as GND (I didn’t want to splice GND Wire.)
- Using PWM for dimming
- Using 5V led, use resistor if using a generic LED (220ohm)
TTP223 sensors are only a few cents!
And react even without touching (< 5mm)
So, you can build this in a case or behind fabric!
NOTE: If you are using an ESP32 you can configure a pin as touch!!!
No TTP223 needed.
But ESP32 are more expensive as Wemos mini.
Code:
#define TOUCH_PIN D2 // My video has D7
#define LED_PIN D6
#define FAKE_GND D5
// Brightness steps (0 = off, 255 = full bright)
int brightnessLevels[] = {0, 150, 200, 255};
int currentLevel = 0;
bool lastTouchState = LOW;
void setup() {
pinMode(TOUCH_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
pinMode(FAKE_GND, OUTPUT);
digitalWrite(FAKE_GND, LOW);
analogWrite(LED_PIN, brightnessLevels[currentLevel]); // start OFF
}
void loop() {
bool touchState = digitalRead(TOUCH_PIN);
if (touchState == HIGH && lastTouchState == LOW) {
// Advance brightness step
currentLevel = (currentLevel + 1) % 4; // 0-3 steps
int pwmValue = brightnessLevels[currentLevel];
analogWrite(LED_PIN, pwmValue);
}
lastTouchState = touchState;
}
Dim levels less obvious on recording, but you can change the levels in the code!
