Please help, 1 input to trigger 3 outputs at varying time delays

Hi All,

I need some help, I’m working on a project for work where I need to have an input from dry contact to trigger three different relays at varying delay times and hold the relays for varying times as well.

So, input received from an external system on input pin, then it starts the delays,

Relay 1 (output pin 9) 10 second delay then hold the pin high for 20 seconds
Relay 2 (output pin 10) 25 second delay then hold the pin high for 15 seconds
Relay 3 (output pin 11) 45 second delay then hold the pin high for 20 seconds

When the input is triggered, I need those delay times to start counting at the same time, not sequentially. Not sure how to do this with Arduino since it basically runs code linearly, not parallel. Any ideas would be greatly appreciated!!!

Take a look at Using millis() for timing. A beginners guide, Several things at the same time and the BlinkWithoutDelay example in the IDE

// Relay 1 (output pin 9) 10 second delay then hold the pin high for 20 seconds
// Relay 2 (output pin 10) 25 second delay then hold the pin high for 15 seconds
// Relay 3 (output pin 11) 45 second delay then hold the pin high for 20 seconds

// Relay 1: HIGH at 10 seconds, LOW at 30 seconds
// Relay 2: HIGH at  25 second, LOW at 40 seconds
// Relay 3: HIGH at 45 second, LOW at 65 seconds

delay(10000);
// 10 Seconds
digitalWrite(Relay1Pin, HIGH);
delay(15000);
// 25 Seconds
digitalWrite(Relay2Pin, HIGH);
delay(5000);
// 30 Seconds
digitalWrite(Relay1Pin, LOW);
delay(10000);
// 40 Seconds
digitalWrite(Relay2Pin, LOW);
delay(5000);
// 45 Seconds
digitalWrite(Relay3Pin, HIGH);
delay(20000);
// 65 Seconds
digitalWrite(Relay3Pin, LOW);

Thanks for your advice guys!!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.