Use Input Pin to provide ground to 12v relay

Hello - a bit of a newbie question i'm sure :stuck_out_tongue:

I have an arduino connected to a 12v vehicle circuit. I want to supply the ground to some of the relays in the circuit. I was going to use the some of the digital input pins to provide the ground but understand they can only operate at max 5v?

So what is my best solution?

  1. 12v Relay Gnd -> 4.7K Resistor -> Diode -> Ardunio Input Pin

  2. 12v Relay Gnd -> Transistor (controlled by Arduino 5v output?) -> Arduino Gnd

  3. Something else? (preferably not another relay :~)

Also, kind of by mistake, I connected the 12v Gnd direct to the input pin acting as ground on a Mega and it didn't seem to fry anything and the relay worked. Was i lucky, or can the input pin operate at 12v as a ground?

Many thanks for any help in advance!

I think what you are talking about here is what is called "Low Side Switching". Using the Arduino to switch the ground connection on and off to switch the relay on and off.

The usual way of doing this is with an NPN BJT transistor or with an N-channel MOSFET.

You would control the base (BJT) or gate (MOSFET) with an output pin from the arduino (usually via a resistor to limit current draw) to turn the power on and off.

Was i lucky

Yes.

Use option 2

Thanks for your help guys. Transistors ordered and on their way 8)

Make sure you use a resistor from Arduino pin to transistor base.
150 ohm, 180 ohm, should be enough to let transistor turn on good & strong without the arduino pin driving too much current.

So just to confirm:

Base = to output pin on arduino (via resistor)
Collector = from 12v Relay gnd
Emitter = to gnd

When i switch arduino output pin to high, the transistor will turn on, complete the circuit with the 12v gnd from the relay and so activate the relay.

Does that sound right?

(btw - here is the data sheet on the transistors ordered = http://www.sparkfun.com/datasheets/Components/2N3906.pdf)

Does that sound right?

Yes. :slight_smile:

Grumpy_Mike:

Does that sound right?

Yes. :slight_smile:

Excellent! thank you