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:
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
- The meaning and importance of circuit protection, common types of circuit protection
- Model rocket launch controller circuit
- Car ice warning circuit sharing
- How to build a simple tachometer using an infrared reflectance sensor
- How can we make the robot move precisely on a predefined path?
- What is a RADAX motor?
- Do-it-yourself trial production of phase failure protection device
- Design and production of no-load automatic power-off device for household power supply
- Bicycle anti-theft alarm
- "Watchdog" anti-theft alarm circuit
- Introducing the CD4013 washing machine timer circuit diagram
- Low power timer circuit
- Timer circuit with long delay
- 2h timer circuit using 558 time base circuit
- High performance timer circuit
- Long timer circuit
- 3 minute to 4 hour timer circuit
- Circuit diagram of a timer that is set as soon as the power is turned on
- Multi-stop timer circuit
- Adjustable timer circuit diagram