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.
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
• 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
USB powers the arduino, the batteries power the solenoid. A jumper grounds the two together.
Step 3: Building the Circuit - Transistor Time
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.
Step 4: Building the Circuit - Connecting the Solenoid
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).