Analogue 12V input

Hi all,

I'm new to Arduino so full of questions and enthusiasm, mostly dumb questions to the group but I'll ask them anyway....

I'm using my Arduino for 12V Automotive applications that will reference the out put and ground of certain circuits.

Looking at the 12VDC inputs, as they can go from 11.5 V - 14.2V dependent on alternator output , if I used a voltage divider to drop the input to say 4.92V for the analogue input at a 14V Input to a divider then at 11.2 V input I'd have an approx 4V input to the same analogue pin.

How would this effect the Arduino in terms of reading the V input as a high or low?

Mainly I need to know how accurate the analogue input needs to be for example to switch a PWM output on the Arduino if an analogue pin receives between 3.5-5 VDC.

Does it need to be 100% accurate as an input voltage or can I write a code to make an allowance for higher or lower inputs?

Thanks

, if I used a voltage divider to drop the input to say 4.92V for the analogue input at a 14V Input to a divider then at 11.2 V input I'd have an approx 4V input to the same analogue pin.

How would this effect the Arduino in terms of reading the V input as a high or low?

The analog input doesn't read "high" or "low". It reads from 0 to 1023.

If you want, you can write some code that essentially says "if the analog reading is over 300 X is high, otherwise X is low."

You really need to know two thresholds... If high is greater than 4V, how is low defined? If your car puts-out a "low" very-near zero volts and a "high" of about 12V then it should be easy to tell the difference between high and low.

For example, a digital input on the ATmega chip reads anything below 1.5V (0.3Vcc) as low and anything greater than 3.5V (0.7Vcc) as high. Anything in-between is undefined (and may read unreliably high or low).

Hello mack85n.
I'm pretty new to the arduino myself. And to this forum so take my reply in that light.
I've been programming for nearly 30 years but only recently started with pi and arduino sized computers due to the "iot boom".

I recently bought a 16 port sainsmart relay board which has 12v input and powers the arduino at spot on 5.00V fixed when it's connected through vcc+ground (the regular way to connect to it VCC, x times out,gnd) . Though you should probably buy an arduino mega to use all ports.

If you need multiple relays in your car related project anyway it's something to consider using.

The things are for sale everywhere.
Here's a pic:

From what I deduce from your question, are you worried about a fluctuating divided 12v for use as the arduino input voltage , then connecting a 5v sensor with an analog return to it's 5v pin ?
The last time I measured the 5V on an arduino using a cheap 5V phone charger which had a 5.25 output, then a dc transfo which was just under 5v that particular arduino gave 4.85v in both cases.

Here's a video of someone using the thing. I'm sure there's more.
As you can see the arduino is not connected to a transfo nor is it connected to usb.

The input this person uses is a 12v transfo connected to the relay board. Which then supplies the arduino with 5V.
In your case it would be a 12v car battery?

@ Phoenixxl
I think that 16-channel relay board should not be promoted.
It has a serious design flaw that could be a problem in certain applications.
That board basically has opto couplers, but no opto isolation. And no way to make it opto isolated.
At least not without seriously hacking the circuit board.
No opto isolation should not be a problem in low voltage applications, but I wouldn't use this board for mains power.
Better use 8-channel relay boards that have a JD-VCC jumper.
Leo..

@wawa

I use 1-8 port opto coupled relay boards for most things.

But in this particular case, running from a car battery, it can function as a power source. Which has to be connected non "opto coupled". The relay board supplies 5V straight to the arduino.
This is the whole reason I mentioned this board.

I would not advise anyone to use it interchangeably with the usual 1-8 opto relay boards from sainsmart at all either. Square peg round hole. This is a whole different beast and I think it has it's uses.

@mack85n

I would also look into regulating the 12v from the car battery before connecting any electronics to it. There's drops when coupling, turning on AC etc no ? I'm sure there's devices you can buy/build for that.

Have you tried one of those cheap cigarette lighter 5V phone charger things? (if you can live without the 12v) I've seen some that are 2.1A. I'm sure there's levels of usability for those too.
Here's a thread about it on this forum:

A user who helped me with my input switch issues yesterday wrote something about it too:
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html
from this thread:

Regards.