Arduino Variable Timer Relay

Some electronic or electrical appliances needs time limited power supply, or usage of some devices are depends on limitted time. To automate electrical devices depends on time simple and robust solution given based on arduino. By using this Arduino Variable timer relay we can control high voltage electrical appliances or electronic devices.

To indicate the time duration and status 16×2 LCD display is included in this design, once the program uploaded to the Arduino then it can work independent with some external battery power source.

Connection Diagram

Construction and Working 

In this project arduino uno board is used to control SPDT (Single pole double throw) Relay and 16 x 2 character LCD indicates the time duration status. Digital pins D2 to D7 are connected to the LCD display. VR1 varible resistor helps to control the contrast of LCD display, Transistor Q1 BC547 reacts as a Switching device and controls the power supply to the Relay coil depends on arduino output.

There are three push buttons are placed to set different time durations, S1 Switch makes the count start, S2 changes the Hours and S3 changes the Minutes of time duration. Output signal from the Arduino is taken from D8 pin and it drives the Relay through transistor.

After making the connection, upload the following arduino sketch and pretest the operation with real timer clock.

Note:- Candle with extreme care if you using High voltage supply at the Relay end.

Arduino Code for Variable timer Relay


#include <LiquidCrystal.h>
LiquidCrystal lcd(7,6,5,4,3,2);
const int set = 9;
int hours=10;
int start=11; 
int relay=8;
int b=0,h=0,t=0;
int buttonState = 0; 
int lastButtonState = 0;
void setup() {
  lcd.print("Adjustable Timer");  
int timer( int b,int h)
void loop() 
         buttonState = digitalRead(set);
       if (buttonState != lastButtonState)
       if(buttonState == HIGH)
           lcd.print("Set time in min:");
         lastButtonState = buttonState;

      if (digitalRead(hours)== HIGH)

              lcd.print("Set time in hours");

             lcd.print("Timer is set for");
             while(digitalRead(start) == HIGH );

8 thoughts on “Arduino Variable Timer Relay

  1. can anybody develop timer for my small vacuum forming machine
    cycle is as below
    first of all servo motor starts (no of pulses should be adjustable)
    heating timer should start ( time pre setable in second 00.0)
    after heating time is complete vacuum time should start( time presetable in seconds)
    after vacuum time is over ejection time should start (00.o sec)
    this cycle should run continously

  2. Nice tutorial
    but how can i make it cyclic? that is, the timer will be on for say 1o minutes and will be off for say 8 hours and it goes on and on like that. also the ON time and OFF tomes shoud be adjustable.

  3. All circuit work ,but set time not show count down reading.after set time relay also cut. But only count down reading not show.

  4. Timer is working.relay is also cut out on set time.only the count down time not working ( show)on the display

Leave a Reply

Your email address will not be published. Required fields are marked *