Running mosfets instead of relays - Project Guidance

Hi,

I am making a project to open a solenoid valve then turn on a pump, then open a second valve and then close them all off.

I wrote this code to test with and I just have LEDs in place of the pump and solenoids but none of the lights light up at all. The messages come through to the serial monitor in the right sequence and at the right timings but the lights are all dead.

Any help with this would be great, I am a newb at this so this is my first project so go easy with me please :slight_smile:

#define pump 2
#define sol1 3
#define sol2 4
#define waitled 11
#define pumpled 12

int spray = (4*1000);
unsigned long wait = (10*1000);
//int timer ;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  
  pinMode(pump, OUTPUT);
  pinMode(sol1, OUTPUT);
  pinMode(sol2, OUTPUT);
  pinMode(waitled, OUTPUT);
  pinMode(pumpled, OUTPUT);
  delay(500);
}

void loop() {
  digitalWrite(pumpled, HIGH);
  Serial.println("pump light");
  digitalWrite(sol1, HIGH);
  digitalWrite(pump, HIGH);
  Serial.println("Pump On");
  Serial.println("Spraying 1");
  delay(spray);
  digitalWrite(sol2, HIGH);
  Serial.println("Spraying 2");
  delay(500);
  digitalWrite(sol1, LOW);
  delay(spray);
  digitalWrite(pump, LOW);
  Serial.println("Pump Off");
  digitalWrite(sol2, LOW);
  digitalWrite(pumpled, LOW);
  digitalWrite(waitled, HIGH);
  Serial.println("Waiting");
  delay(wait);
  digitalWrite(waitled, LOW);
}

Mosfet.PDF (21.8 KB)

Use a series resistor with each LED. 12V and a LED alone will burn out the LED real quick. Arduino output and a LED will burn out the Arduino pin, or the LED, pretty quick too. Most likely the Arduino pin. Add series resistors to all LEDs.

Make sure the LEDs are not connected backwards.

You want a diode connected across the solenoid coil, cathode to power+ and anode to the MOSFET, but the LED connected as you have them drawn.

Why do you have everything that looks it should be Gnd connected to the Reset pin? That's not going to work.

Hi,

Thanks for your reply, I left the resistors off the drawing to save time and I am not too sure about using proteus and can't work out how to unhide the GND pin so I used reset. I also haven't put flyback diodes on for the solenoid or the pump as they are replaced by LEDs just to test the circuit. The LEDs are the right way around for sure but still nothing is happening...

jasonhr:
Hi,

Thanks for your reply, I left the resistors off the drawing to save time and I am not too sure about using proteus and can't work out how to unhide the GND pin so I used reset. I also haven't put flyback diodes on for the solenoid or the pump as they are replaced by LEDs just to test the circuit. The LEDs are the right way around for sure but still nothing is happening...

Hi, have you constructed this circuit, or is it running on a simulator?
If you have built it, can you please post a copy of your complete circuit, in a picture of a hand drawn circuit in jpg, png?
Have you got your LEDs the correct way around, do you have a DMM?
Tom... :slight_smile:

Is that a logic level mosfet?

The datasheet I found doesn't explicitly say it is, and I don't know enough to interrogate the electrical characteristics. (Do logic level mosfets' datasheets typically say "this is a logic level mosfet"?)

Edit: I think for the IRx mosfets, IRL is logic level so presumably IRF is not?

Another edit: Your circuit works for me with an IRL520N logic level mosfet, using a 470R on the gate and a 10k pulldown on the Arduino pin. (Cheated a bit and used 5V on the led-acting-as-solenoid since that's easier to do with just an Arduino and no other power supply handy.)

Hi Tom,

I have constructed the circuit with resistors and all of the parts in place but it still does nothing. I have tried a different arduino, new breadboard, and stripped and rebuilt it several times, I was just taking a sanity check. All of the LEDs are correctly inserted and working when connected separately to a power source.

Hi,
Do you have a DMM?
Can you post a picture of your project, and a hand drawn circuit, it will be more accurate and it will let you do a reverse engineer of your project and find any mis-wired connections.

Can you measure the voltage on the input pins your switches are connected to and measure the voltage when the switch is OPEN and CLOSED.
Measure the voltage with respect to gnd of the arduino.

Thanks.. Tom... :slight_smile: