DIY HOME AUTOMATION - Replace Traditional Light Switches

Turn on or off LIGHTS using touch sensors


  • Capacitive touch sensors are used to turn on the lights instead of traditional mechanical switches.
  • PIR Sensors for automated lights.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Materials Needed

Step 2: LIGHTS- Selecting the Pins for Touch Sensors and Relays

Here 4 capacitive touch sensors are used. Each one is use to turn on or off the light.

How it works? When the sensor the pressed it activated a relay. The light connected to the relay is then activated. To turn off the light the sensor is pressed again.


Pin 22 - Touchsensor1

Pin 23 - Touchsensor2

Pin 24 - Touchsensor3

Pin 25 - Touchsensor4


Pin 26 - Input 1 of relay (Relay1)

Pin 27 - Input 2 of relay (Relay2)

Pin 28 - Input 3 of relay (Relay3)

Pin 29 - Input 4 of relay (Relay4)


Touchsensor1 activates Relay1 and so on...

Step 3: LIGHTS - Selecting Pins for PIR Sensors and Relay

There are two lights that are activated by the PIR sensors.


Pin 30 - PIR1

Pin 31 - PIR2


Pin 32 - Input 5 of relay (Relay5)

Pin 33 - Input 6 of relay (Relay6)


PIR1 activates Relay5

PIR2 activates Relay6

Step 4: Programming the Arduino

// Pins for capactitive touch sensor

#define TouchSensor1 22

#define TouchSensor2 23

#define TouchSensor3 24

#define TouchSensor4 25

// Pins for PIR sensors

int PIR1 = 30; //
int PIR2 = 31; //

int val1 = 0;
int val2 = 1;

boolean currentState1 = LOW;
boolean lastState1 = LOW;

boolean RelayState1 = LOW;

boolean currentState2 = LOW;

boolean lastState2 = LOW;

boolean RelayState2 = LOW;

boolean currentState3 = LOW;

boolean lastState3 = LOW;

boolean RelayState3 = LOW;

boolean currentState4 = LOW;

boolean lastState4 = LOW;

boolean RelayState4 = LOW;

// Pins for relay

int Relay1 = 26;

int Relay2 = 27;

int Relay3 = 28;

int Relay4 = 29;

int Relay5 = 32;

int Relay6 = 33;

void setup() {
//define relays as output

pinMode(relay1, OUTPUT);

pinMode(relay2, OUTPUT);

pinMode(relay3, OUTPUT);

pinMode(relay4, OUTPUT);

pinMode(relay5, OUTPUT);

pinMode(relay6, OUTPUT);

//define touch sensors as input

pinMode(TouchSensor1, INPUT);

pinMode(TouchSensor2, INPUT);

pinMode(TouchSensor3, INPUT);

pinMode(TouchSensor4, INPUT);


CLICK ON THE FILE X.ino to download.

Step 5: CIrcuit Diagram - Wiring Light to Relay

This picture is self- explanatory.

Beware risk of electric shock

Be the First to Share


    • Assistive Tech Contest

      Assistive Tech Contest
    • Reuse Contest

      Reuse Contest
    • Made with Math Contest

      Made with Math Contest

    8 Discussions


    10 months ago on Step 5

    Great idea, interested in it myself as doing home renovation. Few questions:
    How to cover the touch sensors? Plaster over?
    How to connect it and control it with another smart home system to unify with Zigbee / Z-wave supporting system?
    I guess once connected to a smart home system, can also work with Alexa / Siri / Google, or any other way?

    1 reply
    Akshay KoonjaKayaO2

    Reply 10 months ago

    You can use silicon paste to cover it or mold a casing for the sensor
    I don't know about zigbee but if the arduino can be connected to wifi maybe it might work with Alexa,etc


    10 months ago

    I've been mulling over something similar to this for a while now. This looks nicely done.

    This approach has lots of benefits that can be taken advantage of - like having two switches for one light (wiring diagram?).

    Do you have any photos of the final appearance of the touch sensitive pads? I'm curious how they look.

    1 reply
    Akshay Koonjagth-au

    Reply 10 months ago

    thanks.. two switches can be used as a 2 - way switch.
    this is only part of a bulky project so i don't have any pictures to illustrate this one.