Relays not working NEED HELP

Hello all,

I have build a rig to control 4 actuators using Arduino.
Components used as follows:
Arduino Mega 2560
4 channel relay board Link
8 channel relay board Link
10 button remote - custom made
12v battery


void setup() {

pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(A7, INPUT);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
pinMode(A6, INPUT);

void loop() {
// put your main code here, to run repeatedly:
int Aseven = analogRead(A7);
int Azero = analogRead(A0);
int Aone = analogRead(A1);
int Atwo = analogRead(A2);
int Athree = analogRead(A3);
int Afour = analogRead(A4);
int Afive = analogRead(A5);
int Asix = analogRead(A6);


if (((Azero >=600) && (Azero<= 950))|| Afive > 950 ) { //Relay 2 and 13
digitalWrite(2, HIGH);
digitalWrite(13, HIGH);
else (Azero < 200 || Afive < 200 ); { //Relay 2 and 13
digitalWrite(2, LOW);
digitalWrite(13, LOW);
if (((Atwo >=600) && (Atwo<= 950))|| Afour > 950 ) { //Relay 3 and 4
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
else (Atwo < 200 || Afour < 200 ); { //Relay 3 and 4
digitalWrite(3, LOW);
digitalWrite(4, LOW);
if (((Atwo >=600) && (Atwo<= 950))|| Athree > 950 ) { //Relay 5 and 6
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);;
else (Atwo < 200 || Athree < 200 ); { //Relay 5 and 6
digitalWrite(5, LOW);
digitalWrite(6, LOW);
if (Azero > 600) { //Relay 7 and 8
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
else (Azero < 200 ); { //Relay 7 and 8
digitalWrite(7, LOW);
digitalWrite(8, LOW);
if (Atwo > 600 || Athree > 950 || Afour > 950 ) { //Relay 9 and 10
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);;
else (Atwo < 200 || Athree < 200 || Afour < 200); { //Relay 9 and 10
digitalWrite(9, LOW);
digitalWrite(10, LOW);
if (((Azero >=600) && (Azero<= 950))|| Aseven > 600 ) { //Relay 11
digitalWrite(11, HIGH);
else (Azero < 200 || Aseven < 200 ); { //Relay 11
digitalWrite(11, LOW);
if (((Azero >=600) && (Azero<= 950))||((Aseven >=600) && (Aseven<= 950))|| Asix > 950 || Afive > 950) { //Relay 12
digitalWrite(12, HIGH);
else (Azero < 200 || Afive < 200 || Asix < 200 || Aseven < 200 ); { //Relay 12
digitalWrite(12, LOW);

The Problem:

the power LED on the relay board is very bright but when a pin goes high to flick the relay the relay led comes on very dim and doesn't flick the relay.

Wiring Diagram coming shortly

Pleade provide download-links of the datasheets of the relsy modules.

A schematic showing the wiring is crucial
Do you have a digital multimeter?

Do a basic test:
If you connect the relay directly to ground and the inputpin directly to 5V. Does the relay switch?

measuring the current:
Insert multimeter between 5V and relay-inputpin what current do you measure?
What dows the datasheet say about the inputcurrent?

Best regards Stefan


Please follow the advice on posting a programming question given in Read this before posting a programming question

In particular note the advice to Auto format code in the IDE and to use code tags when posting code here

the power LED on the relay board is very bright but when a pin goes high to flick the relay the relay led comes on very dim and doesn't flick the relay.

The obvious question is of course "How are you powering the relays ?' not through the Arduino i hope ?

you could have some bad relays I suppose. clone your program and start small, one relay only. also verify the jumper is set if you are using arduino power to run it. if you have any decent amount of load on these switches you have to power the relays from something else and use common 5v ground. there are tons of diagrams to help you with that part. good luck.

My best guess here is that you are drawing too much current to be able to supply the correct current to power the relays. The suggestions above all have merit, Arduino will not have enough power to do that without using another source of power, try starting small by running one or two relays at a time and then bring in other relays to see where you start getting issues, also what are the power requirements for that particular relay. Just a question/thought, have you considered using a solid state relay? Mechanical relays are power hungry when switching loads or just switching on to off, SS relays are much lower in that respect and the best part they can be optically isolated , no contact wear and quieter. I have used SSR to switch large loads and they work very well, would not use mechanical ones if I could avoid it, no maintenance as far as having to switch them out for wear .Just my 2 cents, good luck.