In this article we are learning how to make a simple Arduino Relay Timer, which can be used to switch power on / off at intervals that are automatically adjusted ON and OFF. For example if you want the light to be ON 24 hours and OFF 2 hours, you can do this by quickly adjusting the program code. In the same way you can customize the output times to any other set of desired times by changing the code correctly.

Arduino Relay Timer Program Code

You just have to compile and upload the following code to your Arduino board and start the timeline according to your requirements. Just Copy and Paste this code in Arduino IDE Software and compile and upload to arduino board 

void setup(){ 

pinMode(13, OUTPUT);

}

void loop(){

digitalWrite(13, HIGH);

delay(86400000);

digitalWrite(13, LOW);

delay(3600000);

}

In the example above code line delay (86400000); and delays (3600000); find output time intervals ON and OFF OFF respectively, in milliseconds. Here, a total of 86400000 milliseconds corresponds to 24 hours, while 3600000 shows a 1 hour delay.

You can customize these two numbers as your preference to get the necessary delays.

Once set and enabled, Arduino will continue to switch between the two steps on / off in sequence. as long as the power is still active in the system.

Connection Diagram For Timer Circuit with arduino uno

The complete circuit diagram along with the Arduino connections is in next Image .You can give 5 to 9 Volt to Arduino Board and relay should also use according to Input Voltage means if your are using 5 volt as input for Arduino use 5 volt relay

arduino relay timer arduino delay microseconds
Click Here To Buy

In this post we learn how to build a simple yet accurate timer circuit using the IC 4060 and some ordinary passive components. Timers were used in many applications in our day to day life. One can see the timers in washing machines,micro ovens etc Read More

Arduino Only One Time Delay Off Timer Circuit

If you don’t want to repeat the timer circuit (on and off continuously)  and you want the timer to be a one time on or off type, which will switch OFF permanently after the set delay, you can apply the following code:

int led = 13;

unsigned long DELAY_TIME = 10000;
unsigned long delayStart = 0;
bool delayRunning = false;

void setup() {
pinMode(led, OUTPUT);
digitalWrite(led, HIGH);


delayStart = millis();
delayRunning = true;
}

void loop() {

if (delayRunning && ((millis() - delayStart) >= DELAY_TIME)) {
delayRunning = false;
digitalWrite(led, LOW);
}
}

Parts Required for the Arduino Programmable Timer Circuit

  • Arduino UNO Board = 1
  • BC547 = 1
  • 1N4007 Diode = 1
  • 1k 1/4 w resistor = 1
  • Relay 5 To 9V = 1
  • 5-9Volt DC Adapter = 1

Watch Video For More Details About Arduino Relay Timer