outsider:
When using the type of relay board that energizes the relay on a LOW input, you should always set the port pins HIGH before pinModing to OUTPUT so there is not a very short ON time before the pin is set to OUTPUT.
digitalWrite(relay1,HIGH);
digitalWrite(relay2,HIGH);
pinMode(relay1,OUTPUT);
pinMode(relay2,OUTPUT);
I see, thanks, although you are saying that the HIGH/LOW Open/Closed status relationship depends on the relay board?
I thought that depended on the Arduino Board and Code.
adwsystems:
pinMode(relayPin[i], INPUT_PULLUP); //Sets the relay pins as pullups. This is to avoid floating state for the pins.
pinMode(relayPin[i], OUTPUT); // sets the relay pins as outputs, defaults state HIGH, relay OFF
Using the pinMode command, you can't have both. INPUT_PULLUP is overwritten by OUTPUT. How are the relays wired? From Arduino Pin to Ground? How many relays are there? How much current does each on require?
1 module of 4 relays opto wired like this:
So basically I should remove the INPUT_PULLUP from there because it has no purpose?