Picture of Controlling solenoids with arduino
tip 120 solenoid breadboard view_bb.png
tip 120 solenoid schematic view_schem.png

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!

Remove these adsRemove these ads by Signing Up

Step 1: Parts

Picture of 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

Step 2: Building the circuit - power connections

Picture of Building the circuit - power connections

USB powers the arduino, the batteries power the solenoid. A jumper grounds the two together.

Step 3: Building the circuit - transistor time

Picture of Building the circuit - transistor time
 When the transistors labeled side is facing up the legs (from left to right) are B, C, E: Base, Collector, Emitter.

We will connect the output pin of the arduino to the Base leg of the transistor through a 1K resistor.  The Collector leg of the transistor will be connected to the ground leg of the device we are driving (our solenoid).  The Emitter leg is connected to the ground channel of our circuit.

1-40 of 45Next »
djmoll91 month ago

Can this be accomplished without usb power?

nodoubtman3 months ago

when the solenoid is active, it tends to heat a lot, what do you do with yours?



nodoubtman3 months ago

when the solenoid is active, it tends to heat a lot, what do you do with yours?



effaowona6 months ago

Hello, the solenoid i'm trying to control has 3 pins. where should i connect these pins? thanks!

iangoh1 year ago
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

See this link, maybe can helpyou.

aavegbarole8 months ago

how many solenoid valves can i trigger using ardunio......i am using it to make programmable fountain.

plzz rply soon

Maybe this link can help you.

Kvnn9 months ago

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?

MichaE Kvnn7 months ago

Hi Kvnn,
I have the same problem, have you found a solution?


chrizbot MichaE7 months ago

I had the same problem because I had connected the diode to the GND rails rather than the SOLENOID V+ rail.

tfedwards8 months ago

This was very helpful! Thanks!!

joesinstructables made it!8 months ago

Nice tutorial, thanks for sharing it.

ctang98 months ago

hello..i aldy connect all the components correctly..but when i turn on my power arduino suddenly give error..i am using 24V solenoid..and using labview interface with it happened because the power supply is unstable?when i measure the power supply it gives 32V instead of 24V..

nodoubtman8 months ago

TIP122 will also work ??


aavegbarole8 months ago

how many solenoid valves can i trigger using ardunio......i am using it to make programmable fountain.

plzz rply soon

Filmguy10011 months ago

Great tutorial. If I want to control two solenoid a do I need two of everything here?

jts3k (author)  Filmguy10011 months ago
yes, two of everything (transistor, diode, resistor...). then just use another output pin on the arduino.
Filmguy100 jts3k11 months ago
Thanks for the reply! Can I use the same breadboard for both or do I need two of them?

You can use one breadboard, just use two different rows.

decon8911 months ago

Nice little tut.. Would be nice to have a little schematic though :)

I have a question. I am trying to create a self watering cabinet. I have bought brass solenoid valve which requires 12V DC to open. Now I would like to control this with my Raspberry Pi. Could I use the same method for my 12V brass solenoid?

This is the valve:
Hi ,
i have the same project,, but my solenoid only push and is difficult to get back ..
could you please post here the program code that u write to control the solenoid ..
thanks in advance
jts3k (author)  saleh jamal1 year ago
That does not sound like it is an issue with your code. You need a spring or some other mechanism to pull the solenoid back. The solenoid can only pull in one direction so you'll need something mechanical to pull it back in the other direction. In this example I used a coiled up piece of wire to function as a spring pulling the shaft back out.

I purchased a solenoid valve . i want to control it from my arduino. I did not get
TIP 120/102 transistor. I got TIP 122 only. Can that be an alternative yo TIP 120? If yes is there any change i need to make with the above circuit? Please reply asap.

ddd16002 years ago
Which pin is the 1K resistor in. Is that pin 13?
ddd16002 years ago
Is there any difference between any of the three GND plugs on the Arduino?
aadot2 years ago
would you be so kind to point out exactly the type of insulated wire for the springs? im having the same problem, i need to fabricate springs for my solenoids...
How do you control how long the solenoid stays open? Thanks!
He is using the basic sketch for a blinking light. Usually this sketch comes with the arduino software for free. The blinker sketch basically flips pin 13 from HIGH to LOW at an interval to blink an LED. In this case pin 13 goes to the solenoid so just modify the delay in the code to make it stay open longer, etc.

If you are looking at the sample code the line you need is:
digitalWrite(ledPin, HIGH);

changing that delay (in miliseconds) will make it stay open longer.

If you need info on uploading or getting the sketch you can check a great tutorial here
I always thought transistors were universally Emitter-Base-Collector.
jts3k (author)  4lifenerdfighter2 years ago
i'm not sure what's most common, but the TIP120 is definitely BCE -
It might be because this transistor is in a voltage regulator style package instead of the normal half-cylinder. But I swear that to92 transistors are ebc.
plasma20023 years ago
You can just simply jump the grounds of different power supplies like that?
Yes you can.

This is only because it is the ground, which creates as he mentions a "common ground" which is needed when running to different power supplies on one system.

If you know anything about PCB design its essential the representation of having a ground plane and everything one the board being grounded to that plane while there could be more than one power supply input throughout the design.
3vilpenguin2 years ago
Is the reason it pulses because of your code? (ie. does the arduino alternate high and low?)

I want to implement this with a push button on/off.

Lastly, does it matter the mAh? I'd like to avoid using 9v batteries and instead use an AC adapter that outputs 12V natively
asyazrin4 years ago
what type solenoid used?
jts3k (author)  asyazrin4 years ago
I'm pretty sure it was this one:

A "continuous duty" solenoid is preferable to "intermittent duty."
Poesis jts3k3 years ago
I bought some solenoids from that website and it didn't come with the springs are they included or was it something you got after to make the solenoid "spring" back?
1-40 of 45Next »