Connecting a Relay to Arduino
Simple circuit to connect a 5V relay to one of the digital output pins of the Arduino. I drew this after a few threads showed up on the Arduino forums, asking about relays. I hope this drawing make things a little clearer for the novices. Best viewed in original size ("Actions>View all sizes" button at lower left).
I've shown a few options for the transistor and diode, but the choice is not critical and almost any NPN bipolar transistor will do. For larger loads (such as big solenoids or motors), you'll need a power transistor that can handle the larger current, and you'll need to reduce R1 to maybe as low as 220 Ohms.
When wiring up, be sure to check the data sheet for the transistor to find the pin connections (e, b, c). The diode will be marked with a band or stripe at the cathode (k) end.
Connecting a Relay to Arduino
Simple circuit to connect a 5V relay to one of the digital output pins of the Arduino. I drew this after a few threads showed up on the Arduino forums, asking about relays. I hope this drawing make things a little clearer for the novices. Best viewed in original size ("Actions>View all sizes" button at lower left).
I've shown a few options for the transistor and diode, but the choice is not critical and almost any NPN bipolar transistor will do. For larger loads (such as big solenoids or motors), you'll need a power transistor that can handle the larger current, and you'll need to reduce R1 to maybe as low as 220 Ohms.
When wiring up, be sure to check the data sheet for the transistor to find the pin connections (e, b, c). The diode will be marked with a band or stripe at the cathode (k) end.