Relay Partially Working on Automatic Watering System

I'm not 100% sure if this is a hardware problem, it may be part of my programming so I'll include the code I am running. You can see that IN4 on the relay isn't on and won't turn on regardless of which digital in the signal is supposed to be coming from. I have IN4 hooked up into digital in 2...

-The relays are supposed to turn on my water pump when my capacitors read >450... all four capacitors were reading around 600 so the sensors weren't the issue.

-When I switch the wiring from IN4 to any of the other digital ins in my code (3,4, or 5) IN4 come on and whenever I take any of the other wires from IN1, IN2, or IN3 and put it into digital in 2, their respective relays do not turn on... here you can see a video of this on my reddit cry for help...

-I have tried to switch the signal for IN4 to 6 and even 7 then edited my code so that it would reflect the hardware change: this is where I may have messed up and think that it is not the hardware but rather a programing error on my part. I change

/*Watering System values*/
int IN1 = 2;
int IN2 = 3;
int IN3 = 4;
int IN4 = 5;


/*Watering System values*/
int IN1 = 2;
int IN2 = 3;
int IN3 = 4;
int IN4 = 6;

and this didn't work.

I started working with any of this stuff 4 months ago when I bought an arduino with the goal of building a self watering garden system and improving on it. This is version 1.0 for me so please be a little patient if there is something I overlooked. Also, any feed back, suggestions, or ideas for improvements are always very welcomed. Any assistance really would be great.

Use CTRL T to format your code.
Attach your sketch between code tags

[code]Paste your sketch here[/code]

To properly enable the relay board opto-isolators, wire to relay aboard as seen here:


In setup() do you have:

pinMode(IN4, OUTPUT);

This looks beautiful... I just checked my code and I do have pinMode(IN4, OUTPUT); in my setup.

I will make these adjustments when I get back to home later.

Is moving the ground from where it currently is to where you have advised providing the common ground from two power sources? Or is there another reason to move the ground on the relay from one to the other?

I'm super grateful for the schematics as well and as a noob I've been chipping away at understanding it and following the signal flow. The external 5v power flows from the source starting its path on IN1 where it gets to the 1/2 box. If the meter has instructed the IN1 to turn the pump attached to IN1 on then the flow would pass through the 1 path on the J7 box, through the R1/VCC box, lighting up the opto-isolator/opto-coupler (red light). Then the flow would, if on, continue through path 4 to allow the circuit to flow past JD-VCC/D1/K1 area then through Q1 onto IN2 to repeat the process given the meter sensor criteria.

Not sure if that made sense... does that sound about right?