solenoids are electromagnets that move along an axis to push something in our out. They are used for locking/unlocking doors or opening or cutting water flow.
In this case we are going to use our Arduino to control a solenoid sending a voltage out of a digital out.
materials: TIP120 power regulator, 1 1N4004 diode, 1 1k resistor, Arduino board, solenoid, and power supply appropriate for your solenoid.
The sources for this tutorial are posts on Adafruit and Instructables.
You will need to make sure that you know what the current draw and voltage are for your solenoid because:
- you will need to use a different design if your solenoid uses more than 4A (which is the limit for the TIP120) or 24 Watts of power which is the limit for this schematic (to calculate total power for your solenoid multiply current times voltage), and
- because if your solenoid works with 12v you’ll need a matching 12v power source.
As with motors and other devices that draw bigger amounts of power, you need an external power source to avoid damaging your Arduino. An important rule to remember going forward is that when you have an external power source you need to connect the ground of your Arduino and that of your external power source together. You’ll see this in the diagram.
This is the schematic we will use:
This translates into this configuration:
Note that the diode has polarity and the ring is on the voltage side. Also, the TIP120 is facing forward.
To make this work, upload the blink code, except this time, make the pin remain at high for a smaller amount of time (80msec is good). If you leave the solenoid on high for a long time, it will end up overheating. An added bonus is that the onboard LED will blink synchronously with the solenoid.