Touch Switch Board using Arduino

In this quick video, we will show you how to make a DIY Touch Switch Board using Arduino, or a Smart Touch Switch. Hope you guys enjoy it.

Like, Subscribe and Share!!

About: TexoBot, previously "Robots-The next species on earth" is a YouTube Channel, where you will find technological, designing, and good to know videos in English. A New Video is Posted Every Week. For business inquiries, please write to texobotenquiry@gmail.com

@TexoBot

Circuit Diagram

Please refer below figure for circuit diagram.

Relay Connection diagram

Please refer below figure for relay connection diagram

Arduino Code

#include <EEPROM.h>

const int Touch_SW1 = 2,Touch_SW2 = 4,Touch_SW3 = 6,Touch_SW4 = 8,LED1= 3, LED2= 5, LED3 = 7, LED4 = 9, Relay1 = A0,Relay2 = A1,Relay3 = A2,Relay4 = A3;

int Touch_SW1_state = 0,Touch_SW2_state = 0,Touch_SW3_state = 0,Touch_SW4_state = 0, Relay1Touch_SW1_state=0 ,Relay2Touch_SW2_state=0 ,Relay3Touch_SW3_state=0 ,Relay4Touch_SW4_state=0 ;

int addr1 = 1,addr2 = 2,addr3 = 3,addr4 = 4;

void setup()

{

pinMode(Touch_SW1, INPUT);

pinMode(Touch_SW2, INPUT);

pinMode(Touch_SW3, INPUT);

pinMode(Touch_SW4, INPUT);

pinMode(Relay1, OUTPUT);

pinMode(Relay2, OUTPUT);

pinMode(Relay3, OUTPUT);

pinMode(Relay4, OUTPUT);


pinMode(LED1, OUTPUT);

pinMode(LED2, OUTPUT);

pinMode(LED3, OUTPUT);

pinMode(LED4, OUTPUT);


Relay1Touch_SW1_state=EEPROM.read(addr1);

Relay2Touch_SW2_state=EEPROM.read(addr2);

Relay3Touch_SW3_state=EEPROM.read(addr3);

Relay4Touch_SW4_state=EEPROM.read(addr4) ;



digitalWrite(LED1,Relay1Touch_SW1_state);

digitalWrite(LED2,Relay2Touch_SW2_state);

digitalWrite(LED3,Relay3Touch_SW3_state);

digitalWrite(LED4,Relay4Touch_SW4_state);


digitalWrite(Relay1,Relay1Touch_SW1_state);

digitalWrite(Relay2,Relay2Touch_SW2_state);

digitalWrite(Relay3,Relay3Touch_SW3_state);

digitalWrite(Relay4,Relay4Touch_SW4_state);

Serial.begin(9600);

}

void loop()

{

if (Touch_SW1_state == 0 && digitalRead(Touch_SW1) == HIGH) {

Touch_SW1_state = 1;

Relay1Touch_SW1_state=!Relay1Touch_SW1_state;

EEPROM.write(addr1, Relay1Touch_SW1_state);

}

if (Touch_SW1_state == 1 && digitalRead(Touch_SW1) == LOW) {

Touch_SW1_state = 0;

}

digitalWrite(Relay1, Relay1Touch_SW1_state);

digitalWrite(LED1, !Relay1Touch_SW1_state);




if (Touch_SW2_state == 0 && digitalRead(Touch_SW2) == HIGH) {

Touch_SW2_state = 1;

Relay2Touch_SW2_state=!Relay2Touch_SW2_state;

EEPROM.write(addr2, Relay2Touch_SW2_state);

}

if (Touch_SW2_state == 1 && digitalRead(Touch_SW2) == LOW) {

Touch_SW2_state = 0;

}

digitalWrite(Relay2, Relay2Touch_SW2_state);

digitalWrite(LED2, !Relay2Touch_SW2_state);



if (Touch_SW3_state == 0 && digitalRead(Touch_SW3) == HIGH) {

Touch_SW3_state = 1;

Relay3Touch_SW3_state=!Relay3Touch_SW3_state;

EEPROM.write(addr3, Relay3Touch_SW3_state);

}

if (Touch_SW3_state == 1 && digitalRead(Touch_SW3) == LOW) {

Touch_SW3_state = 0;

}

digitalWrite(Relay3, Relay3Touch_SW3_state);

digitalWrite(LED3, !Relay3Touch_SW3_state);


if (Touch_SW4_state == 0 && digitalRead(Touch_SW4) == HIGH) {

Touch_SW4_state = 1;

Relay4Touch_SW4_state=!Relay4Touch_SW4_state;

EEPROM.write(addr4, Relay4Touch_SW4_state);

}

if (Touch_SW4_state == 1 && digitalRead(Touch_SW4) == LOW) {

Touch_SW4_state = 0;

}

digitalWrite(Relay4, Relay4Touch_SW4_state);

digitalWrite(LED4, !Relay4Touch_SW4_state);

}