controlling solenoids with arduino@instructables@

          controlling solenoids with arduino by  

Picture of Controlling solenoids with arduino

Step 1: Parts

Picture of Parts




• Arduino board
• USB cable for programming and powering the Arduino
• Some jumper
• 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

Step 3: Building the circuit - transistor time

Picture of Building the circuit - transistor time


The "ground" leg of the solenoid is connected to the collector leg of the transistor. The "power" goes to the high voltage power channel (from our batteries). I put "ground" and "power" in quotation marks because none of the solenoids I've ever used have been polarized so it doesn't matter which lead is connected to ground and which goes to power.

The diode connects the power channel to the solenoid-ground-leg/transistor-collector-leg, preventing the kickback voltage from damaging the circuit. The diode is polarized and should be oriented with white/sliver stripe on the power channel side of the connection.

I'm using a pull-type solenoid rated for 12 to 24 volts (got it here), which has plenty of kick. You'll need some kind of spring to pull the shaft back out after it's been pulled in - I used a small length of insulated wire wrapped around the shaft to create a makeshift spring. In a different sort of configuration one could use gravity to pull the shaft back out (but you'd need some of stopper to prevent the shaft from falling all the way out).

Step 5: Program arduino and enjoy

Now just program the Arduino to drive the appropriate output pins and enjoy. I've connected the transistor to pin 13 so I can see the built-in LED work in time with the solenoid. The sketch I've used is a simple modification of the "Blink" sketch where I've reduced the on time to 80 milliseconds, which is more than enough time to pull the solenoid all the way in.