Multiple DC pumps circuit not working

Hi, can anyone help with my project please (first one). This is using an Arduino Uno R3 to turn two pumps on, one at a time for 1 second each, they are driven from a 12 volt supply (not the arduino supply) so I'm using a 4N35 optocoupler to turn them on. The first pump turns on no problem but the 2nd pump wont turn on at all. Any help with my code or circuit to resolve the problem would be greatly appreciated.

// C++ code
//

const int pump2 = 2;
const int pump7 = 7;

void setup()
{
  pinMode(pump2, OUTPUT);
  pinMode(pump7, OUTPUT);
}

void loop()
{
  // Pump 2
  digitalWrite(pump2, HIGH);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(pump2, LOW);
  delay(1000); // Wait for 1000 millisecond(s)

  // Pump 7
  digitalWrite(pump7, HIGH);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(pump7, LOW);
  delay(1000); // Wait for 1000 millisecond(s) 
}

Are you using a current limiting resistor on the 4N35 input?

An opto-coupler cannot handle the current required by a motor. You need high current MOSFETs.

You also need flyback diodes. Without them, the MOSFETs and opto-couplers will be damaged (they may already be damaged if you connected them like the diagram you posted).

You also need current limiting resistors between the Arduino and the opto-couplers.

You have connected a common ground between the 5V circuit and the 12V circuit, making it pointless to use opto-couplers.

The above replies do cover the issue.

I have just one question why you would connect the negative of the batteries to the GND of the Arduino? It totally defeats the isolation purpose of the optocouplers.

Regarding the mentioned alternative, check Gammon Forum : Electronics : Microprocessors : Driving motors, lights, etc. from an Arduino output pin

Is this for a real circuit or just in the simulator.

If the batteries are not powering the Arduino, you wouldn't need the common GND.

There is no connection from battery plus to Arduino so no need (as we both state) to connect the battery negative to the Arduino GND.

Thanks everyone for the replies, I have changed the optocoupler to a SPDT relay, and now I have the pumps turning on. Would love some feedback on this version too, pick any holes in it before I turn the simulation into a project

@mjs_05
You can't drive relays directly from an Uno I/O pin.
You will need a driver circuit.
What is the current and voltage required by the relay coils?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.