using a relay to turn on a 12 V device

Just wanted to make sure I'm doing this the right way. I'd like to use a digital I/O pin from the arduino to turn on (close) a 12 V circuit.

If I'm not mistaken the way one does this by using a relay. According to my reading you need a 2n2222 transistor in there to keep the chip safe during the relay's switching operations.

So:

arduino digital I/O---resistor ?k ohms----transistor-----relay-----12V + arduino gnd -----------transistor------relay----12V grd

?

I'm stumped.

Simply put I want a 12V circuit to complete (turn on) when I send the HI signal to a digital out pin on the arduino.

There is an example in the playground, http://www.arduino.cc/playground/uploads/Learning/relays.pdf.

In particular, don't skip that diode. I mention this because you didn't. That keeps your relay coil from making a 100V+ spike when you turn it off. That can be a pin or chip killer.

gotcha, that makes some sense. In the diagram what does the symbol with the box with a line through it mean. It is labeled K1 and looks like it breaks out to refer to a simple switch (?).

hi

K1 is the relay...

D

...that's why it look like a switch in the little dotted breakout diagram.

Thanks for the hand-holding guys. I'm not a hardware guy, more of a software guy. I guess it shows... ::)

that's ok, I am a hardware guy.. maybe one day I'll have a software question :)