Go Down

Topic: Controlling a 12 V solenoid valve with Arduino UNO using a L298N motor driver (Read 667 times) previous topic - next topic

yoloyolo

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?

jremington

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

TomGeorge

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.. :)
Everything runs on smoke, let the smoke out, it stops running....

yoloyolo

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?

Code: [Select]


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();
}





jremington

Quote
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.

TomGeorge

Everything runs on smoke, let the smoke out, it stops running....

outsider

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

yoloyolo

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.

jremington

Quote
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.

yoloyolo

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.

robtillaart

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

jremington

Quote
Is there any other way to control solenoid valve without bringing the motor driver into picture??
Please read the entire sentence in post #8.

Go Up