Controlling Solenoid valve with switch

I'm struggling with what I feel like should be a simple issue, and would greatly appreciate any help. I'm brand new to Arduino and trying to get a switch-controlled valve up and running for a project.

I'm following this tutorial for wiring, with the motor replaced with a Solenoid valve. The valve is 12DC, 1.4A. I'm using a 12 V power supply (vs the 9 V in the diagram). Currently, when I press the switch, the LED turns on/off but nothing happens with the valve. With the valve connected directly to a 9 v battery, it pops right open. Do I need to switch to using a relay? I'm not sure what else to change.

My code is below. Thank you!

*/

int pushButton = 2;

int valveControl = 9;

// the setup routine runs once when you press reset:
void setup() {
  // make the pushbutton's pin an input:
  pinMode(pushButton, INPUT);

  // make the transistor's pin an output:
  pinMode(valveControl, OUTPUT);  
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {

  
  if(digitalRead(pushButton) == HIGH){ 
    // ramp up the motor speed
      digitalWrite(valveControl, HIGH);
      digitalWrite(LED_BUILTIN, HIGH);
     
    }
 
    else {
      digitalWrite(valveControl, LOW);
      digitalWrite(LED_BUILTIN, LOW);
      
    }



  delay(1);    
}

At this point in your project, the code is not important. Are connecting the solenoid valve directly to an Arduino pin? I hoe not, you will kill your Arduino, if you have not done so already. Does your tutorial show a transistor between the Arduino and the motor? It should. You cannot power motors and solenoids with an Arduino pin. You can control a transistor with the Arduino pin, when then can control the current to the motor or solenoid.

Paul

Do you have the solenoid connected directly to the Arduino 9 and GND pins ?

An Arduino pin can only supply 5V at a very low current so a 12V 1.4A solenoid is not going to work and you may already have damaged the Arduino by trying to use it.

Using a relay would allow you to switch 12V to the solenoid by driving the relay from an Arduino pin

Just realized I didn't include the wiring. It's based off of this, just subbing in a solenoid instead of a motor.

The valve is not directly connected to the Arduino. I'm using a transistor between them.

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?
What transistor are you using?

We need to see your circuit, can you post a picture of your project so we can see your component layout?

Thanks.. Tom.. :slight_smile:

Sorry about that! A diagram of my circuit is now attached to the first post. I'm using a TIP120 transistor and a 12 V battery supply.

Hi,
OPs diagram;


The gnd of the UNO should be connected the neg/gnd of the motor supply.

Can you please post a copy of your circuit as a proper hand drawn circuit in jpg, png?
Fritzy diagrams are hopeless at debugging signal flow and showing things like transistor pinouts, EBC, BCE, ECB ????

Tom.. :slight_smile:

Why do you need an Arduino to do this ?

Why not control the solenoid with the pushbutton ?