Ok, so this is what my relay looks like. I can't figure out what pins I hook the arduino and transistor to, and what pins to hook the the other device.
Please help.
Ok, so this is what my relay looks like. I can't figure out what pins I hook the arduino and transistor to, and what pins to hook the the other device.
Please help.
Here's a well illustrated similar answer on a different forum.
http://letsmakerobots.com/node/528#comment-15665
(deeplinked images)
A schematic diagram of a relay showing the two coil pins and the three pin switch consisting of normally-open, normally-closed and common (power).
(source: letsmakerobots.com)
A circuit using a transistor to drive the coil and a diode to suppress its back EMF.
(source: letsmakerobots.com)
Don't forget to adjust for the different pinout of your relay.
Connect one end of the relay coil to the 5V rail. Connect the cathode end (the end with the bar) of a diode, such as a 1N4001, to that same end of the relay coil. Hook the other end of the diode to the other side of the relay coil. Connect this side of the relay coil to the collector of an NPN transistor. The emitter of the NPN goes to ground. Hook an output from the Arduino to the base of the NPN through a resistance of about 2.2K ohms.
When you set the output HIGH, check the voltage at the collector of the NPN. It shouldn't be more than about 0.2V; if you see 0.25 or more, try a smaller resistor, but don't go below 500 ohms or you'll be pulling more current from the arduino than you really need to.