• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Circuit Ideas for You

Get free circuit ideas online.

  • Home
  • Privacy Policy
  • About
Home » Arduino 2-Step Programmable Timer Circuit with Independent Output Delay Adjustment

Arduino 2-Step Programmable Timer Circuit with Independent Output Delay Adjustment

Last updated on 15 August 2024 by Admin-Lavi Leave a Comment

An Arduino microcontroller is used in this project to create a versatile timer.

Unlike a traditional two step timer with separate outputs, this circuit focuses on a single output that cycles through two distinct states, each of which has an adjustable delay to allow for flexibility in controlling different applications.

#include <Arduino.h>

// Define pins
const int outputPin = 9;
const int relayDriverPin = 3;  // Adjust for your relay driver

// Define delay values (in milliseconds)
unsigned long delayTime1 = 5000;
unsigned long delayTime2 = 3000;

// Variables to track timer states
unsigned long previousMillis = 0;
int outputState = LOW;

void setup() {
  pinMode(outputPin, OUTPUT);
  pinMode(relayDriverPin, OUTPUT);

  // Initialize relay driver (if necessary)
  // ...
}

void loop() {
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= delayTime1 + delayTime2) {
    previousMillis = currentMillis;
    outputState = !outputState;
  }

  digitalWrite(outputPin, outputState);
  digitalWrite(relayDriverPin, outputState); // Control relay if used
}

Circuit Working:

Arduino 2-Step Programmable Timer Circuit Diagram with Independent Output Delay Adjustment

Parts List:

ComponentQuantity
Arduino Uno Board1
IC 78091
Transistor BC5471
Resistor 10k 1/4 watt1
SPDT 12V Relay1
Diode 1N40071
Connector to Arduino1

The Arduino board configures the output pin and, if needed the relay driver pin.

The loop() method monitors the time since the previous state change.

If the total elapsed time equals or exceeds the sum of both delay times, the output state is reversed (HIGH to LOW or LOW to HIGH).

The output pin and, if applicable the relay driver pin are set based on the current output state.

Description

To generate a sequential two-step output, the code makes use of a single output pin and one timer.

The output state variable rotates between HIGH and LOW.

The overall delay for one cycle is the combination of delayTime1 and delayTime2.

How to adjust the 2-step programmable timer

The start time of each delay period is tracked using two different variables, previousMillis1 and previousMillis2.

The code examines the elapsed time for each delay individually.

When the initial delay (delayTime1) ends, the output state changes to HIGH.

When the second delay (delayTime2) ends, the output state is reset to LOW.

How to Build a Transistor Relay Driver Stage with Arduino:

  • The Arduino digital pin 3 is connected to the transistors base via a resistor 10k for current limiting.
  • The transistors collector is connected to one terminal of the relay coil and other other terminal of relay coil is connected to positive supply +12V.
  • Transistor emitter is connected to ground.
  • The Relay Common Terminal is connected to the load
  • Relay normally closed (NC) or normally open (NO) contacts is determined when the load is connected or disconnected.
  • Connect a diode 1N4007 between the terminals of 12V relay coil
  • Connect a regulated IC 7809 to provide a regulated 9V DC to the arduino board.

Conclusion

This Arduino based circuit offers a versatile and efficient way to build a two-step timer with a single output.

By altering the delay timings, you may tailor the on and off times to specific applications.

The extra relay driver increases the circuits ability to control higher power loads.

References:

How to generate two signals with time delay?

Filed Under: Arduino Projects, Timer Circuits

About Admin-Lavi

Lavi is a B.Tech electronics engineer with a passion for designing new electronic circuits. Do you have questions regarding the circuit diagrams presented on this blog? Feel free to comment and solve your queries with quick replies

Previous Post: « Simple Battery Status Indicator Circuit using Flashing LED
Next Post: DC Motor Speed Controller Circuit using Arduino »

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Categories

  • Alarm Circuits (30)
  • Amplifier Circuits (67)
  • Arduino Projects (29)
  • Audio Circuits (93)
  • Automobile Circuits (19)
  • Battery Charger Circuits (48)
  • Free Energy (13)
  • Heater and Temperature Controllers (9)
  • Indicator Circuits (38)
  • Inverter Circuits (13)
  • LDR Circuits (13)
  • LED and Lamps (111)
  • Meters and Testers (27)
  • Motor Controllers (18)
  • Oscillator Circuits (32)
  • Power Supply Circuits (91)
  • Remote Control Circuits (6)
  • Security and Protection (23)
  • Sensors and Detectors (71)
  • Solar Circuits (16)
  • Timer Circuits (27)
  • Transistor Circuits (56)
  • Transmitter Circuit (12)
  • Tutorials (4)
  • Water Level Controller (4)

Copyright © 2025 | New Circuit Ideas