Controlling a 12 V solenoid valve with Arduino UNO using a L298N motor driver

I am basically trying to control a 12 Volts solenoid valve using Arduino UNO.The valve is to be opened at the time when motor stops.
The 12 Volts DC motor is being driven using a L298 motor driver.Is it possible to control the solenoid valve with the same motor driver or the connection between Arduino and solenoid valve should be different from this setup?

For informed help, please read and follow the directions in the "How to use this forum" post.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

Basically I want to make a system where an IR sensor will detect a cup and stop the 12V DC motor. As soon as the motor will stop,the system would open the solenoid valve (12 V) for a predetermined time period and fill water into the cup.

I am using a L298N motor driver to drive the motor. The driver is also connected to Arduino UNO. My exact question is can the solenoid valve be opened and closed via the second output port of motor driver? The motor driver can run 2 motors simultaneously. Can the solenoid valve be connected in the place of second motor and how??

In this following code in3,in4,enB are for DC motor. A0,A1,A2 are IR sensor pins.Can solenoid valve be connected to ports in1,in2,enA of motor driver?

int enB = 5;
int in3 = 7;
int in4 = 6;

void setup()
{
  
  pinMode(A0,INPUT);
  pinMode(A1,OUTPUT);
  pinMode(A2,OUTPUT);
  digitalWrite(A2,HIGH);
  digitalWrite(A1,LOW);

  pinMode(enB, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
 
}

void demoOne()
     {
  
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  analogWrite(enB, 255);

  
  Serial.println(analogRead(A0));
    delay(1000);
  
  if(analogRead(A0)<800)
   
   {
     digitalWrite(5,LOW);
     delay(5000);

   }
  
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);


}

  
  

void loop()
{
  demoOne();
}

My exact question is can the solenoid valve be opened and closed via the second output port of motor driver?

Yes. Connect the solenoid to the driver exactly as you would any two wire, brushed DC motor.

Hi,
OPs pics.



Tom... :slight_smile:

Is the solenoid current less than the motor board's output rating?

I've tried to connect the solenoid valve into the other port of motor driver. But it seems that current required for operating solenoid valve is much higher than the current required for running the DC motor (Both DC motor and solenoid are 12 V). And that's the reason it isn't working.

Is there any other simpler way to connect solenoid valve to Arduino so that opening the valve for predetermined time period would not be troublesome??

It would be really helpful if code required to operate the solenoid valve is provided.

And that's the reason it isn't working.

Buy a more capable motor driver, or use a low Rds-on, high current, logic-level MOSFET.

jremington:
Buy a more capable motor driver, or use a low Rds-on, high current, logic-level MOSFET.

Is there any other way to control solenoid valve without bringing the motor driver into picture??

Motor driver was used to just amplify the current in order to drive the motor.

Moderator: removed other thread.

Is there any other way to control solenoid valve without bringing the motor driver into picture??

Please read the entire sentence in post #8.