In this instructable we will be building a simple circuit that will allow us to control a solenoid using the popular physical computing platform arduino. I became interested in controlling solenoids for robotic music applications. A similar circuit can be used to control a motor or other devices that require more current than the arduino can provide directly from its output pins.

Since the solenoid requires higher current than the arduino can provide we will be using an alternative power source for the solenoid (a couple batteries) and will be "driving" it with a TIP120 transistor.

The circuit we're using can be found online here. This instructable draws from the excellent documentation in Tod Kurt's bionic arduino workshops.

Build time was exactly one-beer. Excluding the arduino and computer you use to program it, we are using less than $10 in parts. Ok!

Step 1: Parts

• Arduino board
• USB cable for programming and powering the Arduino
• Breadboard
• Some jumper cables
• A 1K resistor
• TIP120 transistor (TIP102 will also work fine)
• 1N4004 diode (1N4001 also works)
• Some batteries and connectors for solenoid power
• A solenoid with leads to connect to the breadboard

<p>Hello, what other alternatives for the TIP120 and TIP102 due to the unavailability of them </p>
<p>i forgot to mention, after checking a mosfet can handle the volts and amps you need, look for RDS on value... that is the resistance through the part when the &quot;switch&quot; is on. n channel is lower but p channel is easier to use and still very reasonably low. </p>
<p>use a &quot;logic level mosfet&quot; they come in N and P variety. N turns on when the gate pin is driven high, p turns on when get is grounded. you can also use p channels as reverse polarity safety devices on stuff you build and frequently connect/disconect power wire... if you tie the gate pin to ground then connect positive through the remaining terminals... the switch will be off if positive gets connected where ground is supposed to be on your power in. ;)</p>
<p>its 2017, use a n or p channel mosfet</p>
<p>I need its ardino code , can u help me?</p>
<p>It should be easy, Its just send a high then low to the correct pin</p>
<p>After recreating the circuit numerous times, I've found that I cannot get the transistor to engage, and that the circuit as I have done it runs current through the solenoid with or without voltage from the digital pin. Is there any explanation for this? I've wired two 9v batteries in series, and am using a 24v solenoid (like one used for a sprinkler). Both my transistor and diode are NTE, but should be interchangeable with the suggested models, as per the catalog. I greatly appreciate any input.</p>
<p>Hello!</p><p><br>What can I do when, after all of the connections are according to the tutorial, the solenoid works with voltage variation (if I change the current for example) and simply it ignores the signal sent by Arduino?</p>
<p>I have the exact same problem. Have you worked out how to fix it? </p>
I just rebuilt the circuit but basing on the photo and not on the scheme.
<p>What's the difference between the photo and the scheme? Just wondering as I am experiencing the same problem.</p>
just wondering if it would be possible to add another solenoid into the circuit and have it run at a different speed than the first solenoid??
<p>yep just duplicate the circuit for any additional outputs and modify the code for the extra output pins</p>
<p>thanks and do you know how i could control the solenoid at differnt speeds?</p>
what is the use of diode in the above circuit???
<p>it prevents &quot;kickback&quot; current from damaging the arduino</p>
how to control the on/off of the solenoid? include into the coding the condition it should be on and off?
<p>where can I buy this solenoid? I am European</p>
<p>I'm doing a project in school and need to operate three solenoids independent of each other. Is there a way to manipulat this setup to do that? Can anyone please help me with that?</p>
<p>Yes u can do that.above shown procedures is for one solenoid,similarily you have to use same circuit for controlling 2 or more solenoid indiviually.use three transistor and make the three circuit indiviual.just u have to use same power supply for all the three thats all</p>
<p>you could use relay for each solenoid. and control those relay with arduino.</p>
<p>Please, I need your help, I am Using the TIP 122 and is hot when the circuits is On, same with the Solenoid, this is normal? or I need to do something?<br><br>Thanks for your answers</p>
This circuit is used to substitute a relay board???
Can look at the codes? Ryply asap.
<p>Nice project..! Do you have any code of solenoid lock or Unlock? please....!</p>
<p>I want to use the pneumatic cylinder at slightly higher switching speeds. Can I use the IN4148 diode? The solenoid valve that I am using works at 24V DC. </p>
Did you minded, if i see your schematic?
Hello - we are currently using your instructions as a reference tool for a project and are confused at the discrepancy of the Arduino board vs the Arduino One board.
<p>i need coding for this above video</p>
<p>Hello, the solenoid i'm trying to control has 3 pins. where should i connect these pins? thanks!</p>
<p>I'd be interested to know as well. I've you figured out how to wire it?</p>
<p>*Have you? (late night typing)</p>
<p>I know this question is a month old, but it might be usefull for other people.</p><p>In valves like these, you have 2 parallel and 1 perpendicular pins. The parallel ones need to be connected to your output driver. It doesnt matter which pin gets the positive/negative or live/neutral. The perpendicular pin is for grounding.</p>
Thanks for the reply :)
I believe that is a solenoid valve for water.
<p>Thank you, this is very helpful to us newbies. </p>
<p>How do you modify the code in order to run twice a day?</p><p>Every 12hrs for exaple for watering plants needs to stay open for 2 mins and repeat?</p><p>What is the difference if i use a relay instead a transistor?</p><p>Thank for sharing</p>
<p>I've used this circuit many times now to control solenoids but also to control motors via pwm. Good Stuff - Thanks for Sharing!</p>
<p>Can this be accomplished without usb power?</p>
<p>when the solenoid is active, it tends to heat a lot, what do you do with yours?</p><p>thanks!</p><p>marC:)</p>
<p>when the solenoid is active, it tends to heat a lot, what do you do with yours?</p><p>thanks!</p><p>marC:)</p>
Could an arduino control nine solenoids (though only one would be in use at any time)? I was thinking how much work it would be to make an automated whack-a-mole out of http://www.thinkgeek.com/product/1270/
<p>See this link, maybe can helpyou.</p><p>sonidiario.tumblr.com/post/35689237364</p>
<p>how many solenoid valves can i trigger using ardunio......i am using it to make programmable fountain.</p><p>plzz rply soon</p>
<p>Maybe this link can help you.</p><p>sonidiario.tumblr.com/post/35689237364</p>
<p>I have done all the steps, but with a TIP126 transistor and a IN4007 diode... when I connect the batteries to the breadboard, the solenoid opens, but nothing related with the Arduino seems to work... what can I do? Is it because of the different diode or transistor?</p>
<p>Hi Kvnn,<br>I have the same problem, have you found a solution?</p><p>Thanks<br>Mike</p>
<p>I had the same problem because I had connected the diode to the GND rails rather than the SOLENOID V+ rail. </p>
<p>This was very helpful! Thanks!!</p>

About This Instructable




More by jts3k:Controlling solenoids with arduino Superterrific Tub Bass 
Add instructable to: