Introduction: DIY HOME AUTOMATION - Replace Traditional Light Switches

Turn on or off LIGHTS using touch sensors

Features:

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

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);

THE FULL CODE IS AVAILABLE TO DOWNLOAD BELOW

CLICK ON THE FILE X.ino to download.

Attachments

Step 5: CIrcuit Diagram - Wiring Light to Relay

This picture is self- explanatory.

Beware risk of electric shock