Muhammad_Munir
Published © LGPL

How to make Timer switches

How to make Timer switches

BeginnerFull instructions provided34
How to make Timer switches

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Push button
×5
Resistor 10k ohm
Resistor 10k ohm
×5
Jumper wires (generic)
Jumper wires (generic)
×1
5 volt Relay
×1

Story

Read more

Code

Code

Arduino
int Relay = 12;
int btn1 = 4;
int btn2 = 5;
int btn3 = 6;
int btn4 = 7;
int btn5 = 8;

int relay1 = LOW;

void setup(){
pinMode(Relay,OUTPUT);
pinMode(btn1,INPUT);
pinMode(btn2,INPUT);
pinMode(btn3,INPUT);
pinMode(btn4,INPUT);
pinMode(btn5,INPUT);
}

void loop()
{
if(digitalRead(btn1) == HIGH)
{
digitalWrite(Relay,HIGH);
delay(300000);                   // 5 min
digitalWrite(Relay,LOW);
}
else if(digitalRead(btn2) == HIGH)
{
digitalWrite(Relay,HIGH);
delay(600000);                   // 10 min              
digitalWrite(Relay,LOW);
}
else if(digitalRead(btn3) == HIGH)
{
digitalWrite(Relay,HIGH);
delay(1200000);                  // 20 min , 20x1000x60
digitalWrite(Relay,LOW);
}
else if(digitalRead(btn4) == HIGH)
{
digitalWrite(Relay,HIGH);
delay(1800000);                 // 30 min
digitalWrite(Relay,LOW);
}
else if(digitalRead(btn5) == HIGH)
{
relay1 = ~ relay1;             // ON/OFF
digitalWrite(Relay,relay1);
delay(500);
}

}

Credits

Muhammad_Munir

Muhammad_Munir

1 project • 10 followers

Comments