12V connect to Arduino Analog or digital pin

Hi,
i am trying to connect the turn signal 12V to Arduino input pin.
since it is 5V i am thinking voltage divider but i think there is a better way..

also is it better to connect to Analog or Digital input and what is the best circuit to use to connect

the Idea to know when the input is high and low to control led on arduino.

If the 12V is regulated a voltage divider is fine. If it's power in a car something like that an [u]over-voltage protection circuit[/u] is safer.

it is not regulated its whatever you get from a car turn signal (a blinking side light)
12-14.5V

Simple voltage divider plus current limiting resistor and TVS is OK.

The voltage divider really is the current limiter. Something in the 10K Ohm range. You can usually get away without the TVS but that is good practice if you expect static electricity from people touching it.

diagram please of how it would look like without the tvs?

Here is the schematic of a resistor voltage divider to drop 15V to approximately 5V for a Arduino digital input.

For added safety (and isolation) you may use an optocoupler.

wvmarle:
For added safety (and isolation) you may use an optocoupler.

But not if you want to make analogue measurements as the transfer function of an opto is not linear.

Of course. But then, turn signals (which OP asked for) tend to be digital.

Point :slight_smile:

Analog turn signals would be great. 6V could mean "I'm thinking of turning at the street after next."

1V would of course mean "I've been driving for 10 minutes with the indicator on solid and the bulb is getting tired."

If the divider outputs betwen about 3.5V and 5V for the normal range of 12V battery voltages,
a digital input is OK to use. An analog input gives more information, but you have to code more...

You can also use an optocoupler i use 4n25 optocouplers. I have a 24v signal and i convert it to a 1.8v to 3.3v signal to work well with the arduino.

groundFungus:
Here is the schematic of a resistor voltage divider to drop 15V to approximately 5V for a Arduino digital input.

would a 5V zener be better choice ? to incase the incoming is between 12.5.and 14.5?

in arduino digital input what tolerance voltage before it give you a high or low ?

Page 322 of the mega328 data sheet.

MorganS:
Analog turn signals would be great. 6V could mean "I'm thinking of turning at the street after next."

1V would of course mean "I've been driving for 10 minutes with the indicator on solid and the bulb is getting tired."

i agree with this, should be a feature by car manufacturers for the smart car (read: dumb driver) - turn signals automatically switch off after 5 minutes (maybe even less, how long really is enough time to indicate your intention to the driver behind ?)

BabyGeezer:
i agree with this, should be a feature by car manufacturers for the smart car (read: dumb driver) - turn signals automatically switch off after 5 minutes (maybe even less, how long really is enough time to indicate your intention to the driver behind ?)

Only 5min? You need to experience some of the lights around here. You don't use turn signals for the benefit of the driver behind you, but to remind yourself what you are doing when you finally get to move

i think this should do it ?

This will mostly result in hot resistors and a hot zener as those resistance values are far too low.

Why don't you just use a 22-100k resistor and connect the 13.9V/0V signal directly to your Arduino's input.

Yes, this is safe. You simply rely on the clamping diodes (rated up to 1 mA) to take care of the over voltage. 22k gives about 0.4 mA through those diodes at 13.9V input.