How To Power on a relay with time delay

How To Power on a relay with time delay

I was looking for a system to power on a relay with time delay and this delay must be controlled by a potentiometer, because each time i wanted different value.

I found many circuits of this 555 timer or something else simpler, but it was not what i wanted. So i build one with Arduino (in particular with Teensy coded by the Teensyduino addon).

Below you can see two simple circuits, to power on a relay with time delay. The time can be controlled by the size of C1 (C2 in the second circuit). You can use these circuits to protect your speakers, too.

I wanted a system to not just open a relay (and then gives power to a three phase motor), but to do and other things as well (like to open another relay and turn the motor backwards).

How to connect a relay on Arduino (Photo from: makezine.com)

Even Arduino do not need many materials, i had to use some other stuff like a 5v regulator, in order to have 12V for relays.

For potentiometer, you can use any potentiometer you may have, because we can modify the values later in our code. To connect it, connect one pin on 5V (+), the other on Arduino/Teensy and the middle pin on (-).

The use of the relay to power up a motor. In the future i will add more relays to do some other things.

Our system is ready. Any time Arduino gets the signal, it will delay to open the relay, according to our potentiometer.

The code i used on Teensey (you can use it on Arduino too). Here is not the whole code, but only the part you will need for time delay relay.

/*
  TimeDelay Power ON and OFF
  Turns on a Relay for a specified time.

By Kraken (https://g3ar.xyz/)

*/

int FrontPin = 0; // Main relay //int BackPin = 2; The other relay, not needed here int MiddlePin = 0; // Our potentiometer //int StartPin = 3; // For adding a switch to start the system, not needed here int LedPin = 11; // The onboard led of teensy is on pin 11

// the setup function runs once when you power the board void setup() { //Serial.begin(38400);

// initialize pins as input-output. pinMode(FrontPin, OUTPUT); //pinMode(BackPin, OUTPUT); pinMode(LedPin, OUTPUT); //pinMode(StartPin, INPUT); pinMode(MiddlePin, INPUT); }

float Delaytime; //int Delaytime = 0; int mode = 0;

// the loop function void loop() { //if (analogRead(StartPin) == LOW) { // To run only after a switch is pressed, not needed here if (mode == 0) { // To run one time only

// Calculate the timing according to potentiometer's middle pin
Delaytime = analogRead(MiddlePin) * 0.5;

delay(Delaytime);
digitalWrite(FrontPin, HIGH);   // turn the Front Relay on (HIGH is the voltage level)
digitalWrite(LedPin, HIGH);   // turn the Front Relay on (HIGH is the voltage level)

// We need this value, in order to keep code from running many times
mode = mode + 1;

}
}

loading