Home > Control Circuits >Timing Circuits > How to Make a Simple 2-Step Arduino Programmable Timer Circuit

How to Make a Simple 2-Step Arduino Programmable Timer Circuit

Source: InternetPublisher:红水杯 Keywords: Timer Circuit Arduino Updated: 2025/01/03

In this article, we will learn how to make a simple 2-step Arduino programmable timer circuit that can be used to control the timer by independently adjustable ON and OFF

Timing to switch the electrical load on/off.

For example, if you want the light to stay ON for 24 hours and OFF for 2

You can do this by quickly modifying the program code. Likewise, you can customize the output timing to any other desired set of time intervals by changing the code appropriately.

void setup(){pinMode(13, OUTPUT);
}void loop(){digitalWrite(13, HIGH);delay(86400000);digitalWrite(13, LOW);delay(3600000);
}

You just need to compile the following code and upload it to your Arduino board and then start the timer function according to your specific application needs.

In the sample code above, the lines delay(86400000); and delay(3600000); determine the output ON and OFF delay time intervals, respectively, in milliseconds. Here, the numbers

86400000 milliseconds corresponds to 24 hours, while 3600000 represents a 1-hour delay.

You can customize these two values ​​to achieve the desired output delay based on your personal preference.

Once set up and powered up, the Arduino will continue to switch between the two-step ON/OFF timing sequence as long as the system remains powered.

Circuit Diagram

The complete circuit diagram along with the Arduino connections can be seen in the image below:

1.png

Arduino Single Pulse Timer Circuit

If you don't want the timer to loop through the two-step timer, but instead want the timer to be a one-shot type, which will go off permanently after a set delay, you can apply the following code:

int led = 13; // Pin 13 has an LED connected on most Arduino boards. unsigned long DELAY_TIME = 10000; // 10 secunsigned long delayStart = 0; // the time the delay startedbool delayRunning = false; // true if still waiting for delay to finishvoid setup() { pinMode(led, OUTPUT); // initialize the digital pin as an output.
  digitalWrite(led, HIGH); // turn led on

  // start delay
  delayStart = millis();
  delayRunning = true;
}void loop() { // check if delay has timed out
  if (delayRunning && ((millis() - delayStart) >= DELAY_TIME)) {
    delayRunning = false; // finished delay -- single shot, once onlydigitalWrite(led, LOW); // turn led off
  }
}

Parts Needed for the Arduino Programmable Timer Circuit

Arduino UNO Board = 1

IC 7809 = 1

BC547 = 1

1N4007 diode = 1

10K 1/4 W resistor = 1

Relay 12V/400 Ohm/SPDT/5A = 1

12V AC to DC adapter = 1

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号