• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Need circuit help? Post them in the comments! I've answered over 50,000!

Blog | Categories | About | Contact | Calculators-online
You are here: Home / Arduino Projects / Arduino 2-Step Programmable Timer Circuit

Arduino 2-Step Programmable Timer Circuit

Last Updated on December 5, 2024 by Swagatam 40 Comments

In this article I have explained how to make a simple 2-step Arduino programmable timer circuit, which can be used to switch an electrical load ON/OFF with independently adjustable ON and OFF timings.

For example if you want a light to remain ON for 24 hours and OFF for 2 hours, you can simply do this through a quick modification in the program code. In the same way you can customize the output timings to any other desired set of time intervals by changing the code appropriately.

You just have to compile and upload the following code to your Arduino board and start the timer function as per your specific application needs.

Program Code

void setup(){
pinMode(13, OUTPUT);
}
void loop(){

digitalWrite(13, HIGH);
delay(86400000);
digitalWrite(13, LOW);
delay(3600000);
}

In the above example code the lines delay(86400000); and delay(3600000); determine the output ON and OFF delay time intervals respectively, in milliseconds. Here, the figure 86400000 milliseconds corresponds to 24 hours, while 3600000 exhibits 1 hour delay.

You can customize these two values as per your personal preference to get the required output delays.

Once setup and powered, the Arduino will continue switching between the two step ON/OFF timing sequence. as long as power remains applied to the system.

Circuit Diagram

The complete circuit diagram along with the Arduino connections can be witnessed in the following diagram:

Arduino programmable timer circuit

Arduino One-Shot Timer Circuit

If you don't want the timer to loop through the two step timer, instead want the timer to be a one-shot type, which will switch OFF permanently after the 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 sec
unsigned long delayStart = 0; // the time the delay started
bool delayRunning = false; // true if still waiting for delay to finish

void 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 only
    digitalWrite(led, LOW); // turn led off
  }
}

If you want a discretely designed version of an identical programmable timer circuit, you can opt for this circuit

Parts Required 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/5 amp = 1
  • 12V AC to DC Adapter = 1

You'll also like:

  • 1.  Make this Home Security Project Using Arduino – Tested and Working
  • 2.  Vehicle Speed Detector Circuit for Traffic Police
  • 3.  How to Make Arduino on Breadboard – Step by Step Instructions
  • 4.  1 to 10 minutes Timer Circuit Diagram
  • 5.  Wireless Office Call Bell Circuit
  • 6.  How to Send and Receive SMS Using GSM Modem

About Swagatam

I am an electronics engineer with over 15 years of hands-on experience. I am passionate about inventing, designing electronic circuits and PCBs, and helping hobbyists bring their projects to life. That is why I founded homemade-circuits.com, a website where I share innovative circuit ideas and tutorials. Have a circuit related question? Leave a comment.... I guarantee a reply!

Previous Post: « Simple Digital Timer Circuit with 2 Digit Display
Next Post: Digital Thermometer Circuit – Uses a Solar Cell for Power »

Reader Interactions

Comments

  1. Scott says

    January 19, 2024 at 9:42 pm

    Can this be made to be rechargeable via usb? Are there a components available?

    Reply
    • Swagatam says

      January 19, 2024 at 10:09 pm

      Your question is not clear, please elaborate…

      Reply
  2. Gelu says

    May 8, 2023 at 8:56 pm

    Mr. swagatam, please if it is possible a timer circuit with repetition that works for example 3 seconds and stops for 2 minutes, then starts again with that time interval. I want the electronic circuit not to be with ardu

    Reply
    • Swagatam says

      May 9, 2023 at 9:39 am

      Hello Gelu, using the above Arduino method is much simpler than using discrete parts. If you do not want the Arduino, then you can use the concept explained in the following article:

      Simple Programmable Timer Circuit

      Reply
      • Gelu says

        May 9, 2023 at 11:09 am

        Tank You Mr.Swagatam

        Reply
        • Swagatam says

          May 9, 2023 at 11:09 am

          You are welcome!

          Reply
  3. Casey says

    April 15, 2023 at 1:08 pm

    Thank you for the information. If I wanted to have a 12v led turning off and on at different times for different durations, would it be possible using the code in the example? For example; on for 15 seconds off for 2 minutes, then on for 27 seconds and off for 5 minutes, on for 22 seconds and off for 4 minutes. Is a sequence like that possible?

    Reply
    • Swagatam says

      April 15, 2023 at 5:52 pm

      No sorry, that may not be possible using this code, you can only select two adjustable timings with this code.

      Reply
  4. Ralph says

    February 14, 2023 at 7:54 pm

    Could you please make me a sketch with these conditions: I have pins 3 & 11 open on a Arduino Uno. All others are used. I’m adding to a Sketch that controls other devices like a Stepper motor and a Servo. I want to: If I put a High into say pin 3, it starts a 0-5 second timer (at the same time I put the High in pin 3, I want it to Output a High on pin 11). After the timer has expired, the Output goes back Low. This in turn will bring the Input pin back low. Now the timer is ready for another Input, to repeat what just happened. I just want to control the Output to turn another circuit on/off. Is this possible? Thanks for any help.

    Reply
    • Swagatam says

      February 14, 2023 at 7:58 pm

      Sorry, my Arduino knowledge is not good at all, so modifying or creating new programs can be very difficult for me.

      Reply
      • Ralph says

        February 14, 2023 at 8:27 pm

        Ok, thanks anyway. My coding isn’t good either! I’m just old and slow lol. I’ve been in electronics for 45 years, but due to personal reasons (I’ve got Tremors) it’s hard for me to do anymore. Anyway, thanks anyway.

        Reply
        • Swagatam says

          February 15, 2023 at 8:53 am

          Thank you Ralph, I appreciate your kind feedback. I hope you can still learn Arduino and fulfill your circuit requirements. All the best to you!

          Reply
  5. abdul says

    November 9, 2022 at 12:35 am

    sir I did not found this arduino board please how can I try to another way to make some

    Reply
    • Swagatam says

      November 9, 2022 at 9:08 am

      You will have to use an Arduino UNO board for this which is easily available through any online store. Other alternative way is to use the following design:

      Simple Programmable Timer Circuit

      Reply
      • abdul says

        November 9, 2022 at 9:58 pm

        this circuit is difficulty found please my senior how to reduced some one is easy circuit micro controller

        Reply
  6. abdulkarim says

    November 5, 2022 at 7:18 pm

    how to control after 2 minutes working also 118 minutes is off 2minutes on / 118 minutes is off

    Reply
    • Swagatam says

      November 5, 2022 at 7:56 pm

      You will have to modify the code values for getting the desired ON/OFF timing.

      Reply
  7. Todd Maurer says

    January 20, 2022 at 7:31 pm

    Swagatam,
    Thanks for posting this. I’d like to add a momentary button to start the timer cycle, how would this be done?

    Thanks,
    Todd

    Reply
    • Swagatam says

      January 20, 2022 at 8:20 pm

      Hello Todd, I am not an Arduino expert, so it may be difficult for me to solve this query.

      Reply
  8. Bjarne Sønderskov Nielsen says

    January 19, 2022 at 5:23 pm

    Thank You for most speedy reply- can I use a potentiometer for adjusting welding time- pause isn¨t’nt so crusial- welding in “spots” isnt always easy to control during the welding proces- maybe i can as experimetnally use a switch for differenting capasitors and a potmeter ,replacing R 2 – to a potentiometer some above the resistance for the fittet resistor- slope value- hoW many ohms for a middelvalue- about 5 sec??

    Reply
    • Swagatam says

      January 19, 2022 at 6:08 pm

      You are welcome! Yes R2 can be replaced with a pot, for example a 500K pot, and C2 with a 220uF capacitor. Mke sure to put another fixed resistor such as 10K in series with the pot R2.

      The circuit will function in the following manner: When power is switched ON, initially the relay will be OFF, and the LED will be OFF. After some delay the relay will switch ON, and then after some more delay the LED will switch ON and reset the relay to OFF, and the cycle will repeat.

      Reply
  9. Bjarne Sønderskov Nielsen says

    January 19, 2022 at 7:50 am

    I’m loving your site with nonsensfree smaal circuit , we all are able to complete. Maybe You can help me too-
    I’m repairing my Welder , a nameless nearly 50 years old co2- welder, app. 250A. By mistake an bad luck i burned the motor for weldingmateriale- core,0,8 or 1mm thiknes- I have chosen to rebuild this velder, when a welder in same quality is pretty expencive- here in DK app 1000 us dollar, and i need a sort of a timer for
    sequence velding, where is is velding for 5 sec and then pause for 5 sec- both period must be adjusteable from maybe 2-10 sec for the welding and maybe same for pause- it must drive a relay, which wil be the contact to the other circuit- and both periodes must be controlled with a potentiometer-hole controlling system is driven by 24 v DC- and of cource- as simpel as possible anit will be built on a trial bord vith velding -dots.
    yours cincerrely Bjarne S. Nielsen

    Reply
    • Swagatam says

      January 19, 2022 at 4:48 pm

      Thank you for liking this site! You can build and try the following transistorized two step timer circuit for your specific application:

      R2 and C2 on both the stages can be adjusted for getting any desired timing for the relay ON/OFF sequencing

      comment image" alt="two step transistorized timer circuit fully adjustable" />

      Reply
  10. Денис says

    January 1, 2022 at 10:01 pm

    Добрый день. Можете помочь со скетчем таймера на ардуино или атини?
    Таймер должен включать и выключать нагрузку на определенное время два раза в день.

    Reply
  11. Jix says

    October 6, 2021 at 6:46 pm

    Can I use arduino nano instead of arduino nano?

    Reply
    • Swagatam says

      October 6, 2021 at 8:01 pm

      Yes you can use it…

      Reply
  12. Wilson says

    March 22, 2021 at 11:45 am

    Hello, sorry if this may seem off topick, am trying to make a inverter using arduino uno, am not good in cording so i generated a code from an android app, the inverter seem to be working ok, the only problem i have is how to give it feedback so the output voltage can be stable.
    below is the generated code

    #include

    #define HO1 12
    #define LO1 11
    #define HO2 10
    #define LO2 9
    int f_sin=50;
    int f_pwm=10000;
    float sin_buffer[200];
    float sampling_tot,pwm_period,sin_period,us=1000000;
    int count=0,flag=0,Ampli=1000;

    void setup() {
    Serial.begin(9600);
    pinMode(HO1,OUTPUT);
    pinMode(LO1,OUTPUT);
    pwm_period=(us*1)/f_pwm;
    sin_period=(us*1)/f_sin;
    sampling_tot=(sin_period/pwm_period)/2.0;
    Serial.println(pwm_period);
    Serial.println(sin_period);
    Serial.println(sampling_tot);
    for(int deg=0;deg(sampling_tot) && flag==1 ){
    flag=0;
    count=1;
    TCCR1A=0b10110000;
    }
    if(count>(sampling_tot) && flag==0 ){
    flag=1;
    count=1;
    TCCR1A=0b11100000;
    }
    count++;
    if(flag==0){
    Timer1.pwm(HO2,sin_buffer[count]* Ampli);
    Timer1.pwm(LO2,sin_buffer[count]* Ampli);
    digitalWrite(HO1,HIGH);
    digitalWrite(LO1,LOW);
    }
    if(flag==1){
    Timer1.pwm(HO2,sin_buffer[count]* Ampli);
    Timer1.pwm(LO2,sin_buffer[count]* Ampli);
    digitalWrite(HO1,LOW);
    digitalWrite(LO1,HIGH);
    }
    }

    Reply
    • Swagatam says

      March 22, 2021 at 8:13 pm

      Hello, if the inverter is working that means the code should be fine too…sorry, just like you I am too not good with coding stuff, so won’t be able to help you much in this regard.

      Reply
  13. Sunshine says

    February 7, 2021 at 11:03 pm

    Good day sir…happy Sunday…please I want be familiarize with arduino system..please help..how do I give a command it or program it? Thanks Engr.

    Reply
    • Swagatam says

      February 8, 2021 at 8:00 am

      Hello Sunshine, You can read the following article to get some basic tips regarding Arduino programming:

      Learning Basic Arduino Programming – Tutorial for the Newcomers

      Reply
  14. Sanjiv Kumar Mohbansi says

    August 22, 2020 at 1:15 pm

    Dear Sir;
    I am in need of Arduino controlled reverse and forward relay controlled project details.
    Following are the steps:-
    1. After power ON, only after pushing ON push button (PB1), after 15 seconds, both relay1 (Motor1) and relay2 (Motor2) will start automatically simultaneously and stopped simultaneously, by pushing OFF push button (PB2) .
    2. Relay3 (Motor3) will remain stopped, unless and until we press direction change push button (PB3).
    3. When we will press PB3, relay2 stops and relay3 will ON after a timing gap of 15 seconds. Both relay2 and relay3 are interlocked. And stopped through PB2.
    4. Along with PB3, there is also provision for a proximity switch (PB3 OR proximity switch) to change direction as per step number 3.
    5. All three relay1, relay2 and relay3 will start with PB1 and stopped with PB2.
    6. Relay1 is controlled with PB1 and PB2 only.
    Thanks in advance for your kind guidance and support.
    Sanjiv Mohbansi
    [email protected]

    Reply
    • Swagatam says

      August 22, 2020 at 5:35 pm

      Dear Sanjiv, I am not good with Arduino coding, so won’t be able to help you with this project.

      Reply
      • Sanjiv says

        August 26, 2020 at 6:14 pm

        Thank you Sir for your kind reply!!
        Else as per your view, is there any option without using Arduino??
        Awaiting your suggestion.
        Thanks in advance!!

        Reply
        • Swagatam says

          August 27, 2020 at 3:04 pm

          Yes it is possible using a simple flip flop circuit

          Reply
  15. Dan says

    June 10, 2020 at 5:37 am

    Please Sir can you elaborate on how to load a bootloader to ATMEGA 328?
    Thank you

    Reply
    • Swagatam says

      June 10, 2020 at 10:38 am

      Sorry Dan, I have no idea about it.

      Reply
  16. Dan says

    June 8, 2020 at 4:25 am

    Thank you very much Sir for your quick responds. its exactly what I need.

    Reply
    • Swagatam says

      June 8, 2020 at 7:35 am

      You are welcome Dan!

      Reply
      • Dan says

        June 9, 2020 at 4:28 pm

        wow Thanks a lot Swagatam the code (sketch) is working very well.

        Reply
        • Swagatam says

          June 9, 2020 at 5:37 pm

          Glad it’s working Dan, hope you succeed with the project.

          Reply

Need Help? Please Leave a Comment! We value your input—Kindly keep it relevant to the above topic! Cancel reply

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

Primary Sidebar

Subscribe to New Circuit Ideas

Categories

  • Arduino Projects (87)
  • Audio and Amplifier Projects (132)
  • Automation Projects (17)
  • Automobile Electronics (101)
  • Battery Charger Circuits (82)
  • Datasheets and Components (102)
  • Electronics Theory (143)
  • Free Energy (37)
  • Games and Sports Projects (11)
  • Grid and 3-Phase (19)
  • Health related Projects (25)
  • Home Electrical Circuits (12)
  • Indicator Circuits (14)
  • Inverter Circuits (87)
  • Lamps and Lights (142)
  • Meters and Testers (69)
  • Mini Projects (46)
  • Motor Controller (64)
  • Oscillator Circuits (27)
  • Pets and Pests (15)
  • Power Supply Circuits (108)
  • Remote Control Circuits (50)
  • Security and Alarm (64)
  • Sensors and Detectors (100)
  • Solar Controller Circuits (59)
  • Temperature Controllers (42)
  • Timer and Delay Relay (49)
  • Transmitter Circuits (29)
  • Voltage Control and Protection (37)
  • Water Controller (36)

Calculators

  • Battery Back up Time Calculator
  • Capacitance Reactance Calculator
  • IC 555 Astable Calculator
  • IC 555 Monostable Calculator
  • Inductance Calculator
  • LC Resonance Calculator
  • LM317, LM338, LM396 Calculator
  • Ohm’s Law Calculator
  • Phase Angle Phase Shift Calculator
  • Power Factor (PF) Calculator
  • Reactance Calculator
  • Transistor Astable Calculator
  • Transistor base Resistor Calculator
  • Voltage Divider Calculator
  • Wire Current Calculator
  • Zener Diode Calculator
  • Filter Capacitor Calculator
  • Buck Converter Calculator
  • Boost Converter Calculator
  • Solar Panel, Inverter, Battery Calculator
  • Wire Current Calculator
  • SMPS Transformer Calculator
  • IC SG3525, SG3524 Calculator
  • Inverter LC Filter Calculator

People Also Search

555 Circuits | 741 Circuits | LM324 Circuits | LM338 Circuits | 4017 Circuits | Ultrasonic Projects | SMPS Projects | Christmas Projects | MOSFETs | Radio Circuits | Laser Circuits | PIR Projects |

Recent Comments

  • Swagatam on Simple Delay Timer Circuits Explained
  • Swagatam on The Role of Inductor Coil in SMPS
  • Swagatam on 7 Modified Sine Wave Inverter Circuits Explored – 100W to 3kVA
  • Swagatam on 7 Modified Sine Wave Inverter Circuits Explored – 100W to 3kVA
  • Victor on 7 Modified Sine Wave Inverter Circuits Explored – 100W to 3kVA

Company

  • Privacy Policy
  • Cookie Policy
  • About Me
  • Contact
  • Disclaimer
  • Copyright
  • Videos
  • Sitemap

Social Profiles

  • Twitter
  • YouTube
  • Instagram
  • Pinterest
  • My Facebook-Page
  • Quora
  • Stack Exchange
  • Linkedin
  • © 2025 · Swagatam Innovations