Can a UNO control two seperate relays from one input?

I need some direction here on where to start. Arduino Uno. I want to control two separate relays with one input signal. The input signal will be a second or two and then nothing [N.O. push-button]. Both relays will energize at the same time. One relay will stay energized for 5 seconds and then drop out. The second relay will stay energized for 90 seconds and then drop out. The relays are 4 channel (only will use two) relay modules for Arduino.

I'm new at the Arduino but experienced in electronics so some guidance is needed.

Thanks for looking.

(deleted)

OK - - - - and this is considering that the input is only momentary? Sorry if I seem a little dense - I am a little dense so it is natural. So the outputs will remain high until instructed to turn off [go low] no matter the state of the input?

Thanks Spycatcher for your input.

The input will be quite separate from the outputs that control the relays.

The input can be either momentary (such as a push button press-on release-off switch) or long term like a toggle switch.

How long the relays stay on can be (but does not have to be) completely independent of how long the switch is on.

It would help if you describe the project you are trying to implement.

...R

The input can be either momentary (such as a push button press-on release-off switch) or long term like a toggle switch.

Regardless of which kind of switch you are using, there is one state change when the switch is pressed or released or toggled. Make use of that fact. The state change detection example shows how.

Robin2: .

It would help if you describe the project you are trying to implement.

...R

The project is working now but it gets "confused" once in a while. I have a wireless motion detector on the front porch that triggers an LED flood light and also triggers a display in the TV room. The flood stays on 90 seconds and the display stays on for 5 seconds. They are 50' apart [display and flood] and operate on 9vdc. The flood is operated by a small relay triggered by a 555 timer in "one shot" mode [90 seconds], and the display is operated by a 555 timer "one shot" [ 5 seconds] that triggers another 555 timer in "astable" mode [pulse every 200 nanoseconds] which sends the pulses to a 4017 decade counter which sequences 10 superbright LEDs [various colors] for 5 seconds. It is a display to alert my wife that someone is at the front door while she is in the TV room.

Occasionally if the person at the front door continues to move about briskly and continuously keeps triggering the motion detector - the timing sequence "gets confused" - this is why I want to do the triggering with relays - so I can isolate the two controls electrically.

Confusing but it works well - I just want to simplify the trigger that starts it all. Have the motion detector trigger the aurdino uno, Yes I have uncoupling caps, pull down and pull up resistors on both triggers. But am forced to operate it all off one power supply at present so it can be shut off.

The Arduino would solve the backfeed/inductance/spooks in the system by the two relays.

Occasionally if the person at the front door continues to move about briskly and continuously keeps triggering the motion detector - the timing sequence "gets confused" - this is why I want to do the triggering with relays - so I can isolate the two controls electrically.

If I understand that correctly, the system reacts on 'false' triggers. If so, it sounds like you need to 'disable' the sensor during the 90 second period. A little bit of additional logic with e.g. some NAND gates might be able to do the trick in your current setup.

And yes, an Arduino can do it as well ;)

Thanks for the reply. Yes, adding additional components can/will solve the false triggering but then the circuits get even more complicated - which is the fun and rewarding part - but changing or adjusting "time" involves soldering and I was hoping to get away from that part.

I was hoping that the arduino would be able to simplify changes and add reliability.

Is there a relay timing sketch that would be a good place to start with?

void loop()
{
  // startTime when trigger occured; will be remembered
  unsigned long startTime = 0;

  // if relays not activated (start time will be zero) and sensor activated
  if(startTime == 0 && digitalRead(sensorPin) == LOW)
  {
    // switch relays on
    digitalWrite(relay1, HIGH);
    digitalWrite(relay2, HIGH);
    // set the start time
    startTime = millis();
  }

  // check if it's time to switch the relay off
  if(startTime!=0 && millis() - startTime >90000UL)
  {
    digitalWrite(relay1, LOW);
  }
  if(startTime!=0 && millis() - startTime >5000UL)
  {
    digitalWrite(relay2, LOW);
  }

  //read back relay status to determine if cycle is completed
  if(digitalRead(relay1) == LOW && digitalRead(relay2) == LOW)
  {
    startTime = 0;
  }
}

Something in this line ... ? You have to do the pin definitions and the setup() ;)

Good place to start. Thanks.