# Arduino and Relay with the same power source

Is this circuit possible?

The goal is to power the led IF the IG is switched on AND the pin 13 of Arduino is in HIGH mode. Both the relay and the Arduino is powered by the same battery.

Note: this system will not be connected to an actual car so voltage fluctuation is not a concern here.

Note 2: the ACC terminal is also powered when the IG is switched on but NOT vice versa.

12V is on the upper recommended Arduino limit.

12V is twice what you say the relay's expecting.

I would be more inclined to sense the 12V as 5V on a digital input with a divider. Then if that's high, make 13 high.

Thanks for the reply! So what am I suppose to add to this circuit?

godsuave:
Thanks for the reply! So what am I suppose to add to this circuit?

Lose: the relay

Add: a 4.7k 6.8k voltage divider with the midpoint to an input with a pull-down resistor to make sure it's 0 when it's not 5. Ignore that: brain-fart... the bottom part of the divider is the pulldown.

Ok thanks! I will try that.

Check the output from the divider before input to Arduino: make sure it's never above 5V.

Depends how much faith you have in your 12V not being above 12V. If it's a fully charged car battery even if it's not in a car, that can be about 14V. You can re-jig the divider values according to that site to drop 14 or 15 to 5V, but then test if it's still a high enough output to be a "high" to the Arduino if it's actually 12V or the battery discharges to say 11V.

Hi,
Circuit like this.

Tomâ€¦

Yeah analog input's better, then OP can mess around with his high/low threshold.

Still may need to re-jig the resistor values to cater for ~14V though, so as not to go over 5V.

TomGeorge:
Hi,
Circuit like this.

Tomâ€¦

Thank you very much for this! I will try this later

We always check the voltage of the battery and it never achieved higher than 12V so I guess it is safe but I will keep that in mind manor

BTW, what would be the code for this? I'm guessing pin13 is just digitalWrite but what about pin A0?

Then you'll need to have a variable called say "threshold" and initialise it equal to some value (out of 1023 max, say (wild guess) 900) and then in an "if" check to see if the value you read in is > threshold. If it is, turn the led on, else turn it off.

(threshold is the value over which there is deemed to be life on the pin. Cater for battery being flat by making threshold lower.)

Thanks a lot!

Use the design made by Tom George

Use a 2K2 resistor instead of 4K7 for R2. This will protect you from higher voltages than 12V.

Make your threshold for detecting a 12V at A0 to 100.

If you got more than 100 you will have several Volts at your input.
All you want to know, if there is a 12V or not.