Controlling 2 channel Relay separately

Hello everyone
I need some advice, or maybe help from you.
I have a project, about flood early warning system.
this system using Strobe Light and Motor Siren as alarm, connected to 2 channel relay as power switch (connected to Normally Open). when the alarm switch on, i need to state the Strobe Light ON continuously while the Motor Siren switching ON/OFF with 3 second interval. it's that possible to do? i have been working on millis, but still i can't make it work separately.
Please help. Thank you

Here's the code that i have been trying for alarm switch and the wiring diagram

unsigned long previousMillis = 0;
int relayState = LOW;

const long interval = 3000;
const int relayStrobe = 7;
const int relaySiren = 6;

void setup() {
      pinMode(relayStrobe, OUTPUT);
      pinMode(relaySiren, OUTPUT);
}

void loop() {
      digitalWrite(relayStrobe,HIGH);
      unsigned long currentMillis = millis();
      if (currentMillis - previousMillis >= interval){
        previousMillis = currentMillis;
        relayState=!relayState;
        digitalWrite(relaySiren,relayState);
      }

}

Yes

Please post what you have tried and tell us what happens when you run it

Always show us a good schematic of your proposed circuit.
Show us a good image of your β€˜actual’ wiring.
Give links to components.

At least show us your components.

thank you
i have update my post. please take a look

i have update my post, please take a look.
thank you

A Motor Siren can cause huge electrical noise which might reflect back on the Arduino causing problems.

Give links to the strobe and Motor Siren.

We do not recommend using the Arduino to supply power to relays or high current loads.

both of components working on 12VDC and connected to external power source, both of components only provide with 2 wire for input, GND wire and 12VDC wire. 12VDC external power source connected to relay Com terminal, so i use the relay to control the power. should i connect the relay to my external power source too?
thank you

here is the link for the components
for the strobe


and the siren
https://images.tokopedia.net/img/cache/700/product-1/2017/10/31/2641700/2641700_d532b8b5-7044-40fb-bd37-b40f9a21b0c3_640_640.jpg.webp?ect=4g

What happens when you run your code?

This siren is going to cause no end of problems.

Your Songle relay will not be enough.

Suggest you use your relay module to then control a second relay like a KRP-11DG-12. Of course the current ratings are important too.


void loop() 
{
      digitalWrite(relayStrobe,HIGH);  //remove this line <β€”β€”β€”<<<<
      unsigned long currentMillis = millis();
      if (currentMillis - previousMillis >= interval){
        previousMillis = currentMillis;
        relayState=!relayState;
        digitalWrite(relaySiren,relayState);

        digitalWrite(relayStrobe, !digitalRead(relayStrobe) );  

      }

}

the relaySiren working, blinking every 3 second
but nothing happen with relayStrobe, there is no sign that relay working. i have try to switch the pin from the program, still the same problem, even try switch the wiring in arduino, still the same nothing happen with relayStrobe. it is that power issue? i am wondering the current that drawn from the arduino it is the problem

why still using secondary relay? it is that the issue with the current rating?
thank you

i will try to run this program and update the result.
thank you for helping

The current draw of the siren must be less than the current rating of the relay contacts.

Songle relays are notorious for welded contacts.

Your Songle relay would drive the KRP which then controls the motor siren.

Having two relays like this helps isolate the noise (electrical) load from the Arduino.

Believe your relay module requires a LOW on the input for the relay to energize.

the program makes the both relay blinking at the same time. i have done that before.
the problem is the strobe light it is rotating, there will be a misconception with the alarm if the rotating light turn ON and OFF. so when the alarm switch ON, the relayStrobe should be always ON while the relaySiren switch ON/OFF every 3 second continuously.

okay, get it sir. thank you

Are you saying the siren now turns on/off ?

If so, you need to write a LOW to the siren relay for the siren to energize (turn ON).

digitalWrite(relayStrobe, LOW); // This turns ON the siren
And
digitalWrite(relayStrobe, HIGH); // This turns OFF the siren

If this system is of any real importance, you will probably want to get rid of that relay module altogether. It was no doubt very inexpensive and that has poor implications for the longevity of the relays which are basically jellybean components. As @LarryD said, they have a tendency to weld their contacts shut.

i think there is a misconception between siren and strobe here.
the strobe and the siren it is 2 working component with 2 different control. 1 relay control the strobe light and the other relay control the motor siren.
what i want to do is, make the strobe light always on using 1 relay, while the motor siren keep turn on and off every 3 second.