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);
}
}
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
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
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.
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.