USB supply or Arduino's onboard supply can't power more than two relays at the same time.
You must use a separate supply to power the relay boards.
A separate supply can also give opto isolation if connected right.
Remove the JD-VCC jumpers.
Connect a 5volt/1.5Amp supply to the JD-VCC connectors(+) and the grounds(-) of the relay boards.
A 5volt/1.5Amp or 2Amp tablet supply/charger could work.
Connect the two VCC connectors (not JD-VCC) to the Mega's 5volt pin.
Connect the 16 inputs to 16 output pins. DO NOT connect relay ground to Mega ground.
Ground has no function here.
And if you share ground, you don't have opto isolation.
Do this in void setup()
digitalWrite(relayPinOne, HIGH);
digitalWrite(relayPinTwo, HIGH);
etc.
pinMode(relayPinOne, OUTPUT);
pinMode(relayPinTwo, OUTPUT);
etc.
This stops relay chattering during bootup.
These boards use inverted logic.
A HIGH is relay not active, a LOW is relay active.
Leo..
Wawa:
USB supply or Arduino's onboard supply can't power more than two relays at the same time.
You must use a separate supply to power the relay boards.
A separate supply can also give opto isolation if connected right.
Remove the JD-VCC jumpers.
Connect a 5volt/1.5Amp supply to the JD-VCC connectors(+) and the grounds(-) of the relay boards.
A 5volt/1.5Amp or 2Amp tablet supply/charger could work.
Connect the two VCC connectors (not JD-VCC) to the Mega's 5volt pin.
Connect the 16 inputs to 16 output pins. DO NOT connect relay ground to Mega ground.
Ground has no function here.
And if you share ground, you don't have opto isolation.
Do this in void setup()
digitalWrite(relayPinOne, HIGH);
digitalWrite(relayPinTwo, HIGH);
etc.
pinMode(relayPinOne, OUTPUT);
pinMode(relayPinTwo, OUTPUT);
etc.
This stops relay chattering during bootup.
These boards use inverted logic.
A HIGH is relay not active, a LOW is relay active.
Leo..
Thank you so much, I've taken an old USB charger based on your suggestions above.
One other general question though: The Arduino is no longer able to trigger the relay board. How do I safely check for damage on the Arduino and relay board? I read that using multimeters on the Arduino could damage it.
Not a problem to measure the pins with a DMM.
How do you supply the Mega.
You could start by measuring the 5volt pin.
Then load a sketch, like "blink" from the examples in the IDE.
Change the pin number, and see if the pin goes high and low.
Post your relay sketch and a picture of the setup.
Maybe we can see if there is something wrong there.
Leo..