12 volt input?

Hi all, this more than likely been asked before but I have not been able to find anything in the history, so excuse me if it’s a repeat.

I am using an Arduino Uno to make a low tech data acc for a race car, the customer has a GOPRO camera that looks out the front of the car and I can mount the Ardino on the dash.
The cars TPS is a 5 volt reference to the stock ECU, found a sketch on Fritzing for that light array.
Now I need to tap into the stop lamp switch and here is my question…
Can the Uno handle a 12 volt input and what pin do I use.
Thanks All in advance

8)Linc

(deleted)

Thats what i thought :0

You would not know off hand what resistor would bring the voltage down to 5v?
And then would it go into an anolog input pin?

8)Linc

(deleted)

(deleted)

Thanks Drew!
And thanks even more for the diagram, was not sure what you were talking about but I can follow wires.
Not going to be able to use a digital input I have them all tie up for the led outputs.
I see where you can change the analog input to a digital in, I'll have to do some reading on how this is accomplished and try to write in the sketch.

8)Linc

(deleted)

I see where you can change the analog input to a digital in, I'll have to do some reading on how this is accomplished and try to write in the sketch.

Linc,

I use my analog inputs as digital inputs, it is valid. Try the following:

pinMode(A0,INPUT);
digitalRead(A0);

BTW: Analog pins A0-A5 on the UNO can also be referred as pins 14-19. Specially useful if you set or read or write the pins using a program loop. ie: for i=1,... and the same works with the MEGA2570's A0-A15 which also are 54-69.

  • splitting it with 7K/5K splits the voltage across the resistors 7v/5v.

spycatcher2k,
Thanks for the easy explanation on voltage dividers and the 'wise' values chosen for the resistors since it is very easy to see how it works. But why did you use those specific values and not 3.5K and 2.5K? Is it also because of the current draw?

Thank you!

(deleted)

12V in a car is actually about 13.8V if the engine is running, since the battery is being charged. Use a 10k and 5k6 divider perhaps?

This all makes sense to me, thanks all for making it easy for me to understand!
I can tell you how to fix a car and why but when it comes to this type of manufacturing things, I have learned long time ago...ASK SOMEONE who knows what he is doing! :slight_smile:

So for the divider 10K to 5K6 resistor.

Program analog pin A1 as
pinMode(A1,INPUT);
digitalRead(A1);

So I now have A0 set for the cars TPS that runs a 5 volt reference to the ECU and running a 10 led array
Brake input through the resistor divider
Then the clutch pedal input with a simple momentary closed switch.
Just now have to wait for the box, circuit board and other pieces to put it all together …
What do you guys think, an accelerometer to show fore and aft G’S and lateral, or am I getting into to deep? LOL

Linc

spycatcher2k,

Thank you. I had an idea of how a voltage divider worked and I knew the equations. I also knew that in the particular case when R1=R2, you get half the input voltage. Ok, but should R1=R2 equal 1k or 10k or 100k??? That, I didn't know. It seems to me that the right choices are in the range of 5k to 10k in order to keep a modest current flowing. Besides I guess that you also chose 7k and 5k because, for example, 500 and 700 ohm resistors are not standard values, maybe 470 and 7??. Thanks again, Drew! :slight_smile:

Linc,

This all makes sense to me, thanks all for making it easy for me to understand!
I can tell you how to fix a car and why but when it comes to this type of manufacturing things, I have learned long time ago...ASK SOMEONE who knows what he is doing!

Wise decision. I'm very glad we learned something new to keep us going, and now that we've "ASKED", from now on, others will soon ask us for the same things and how we developed our projects. That's why I like this Forum. 8)

What do you guys think, an accelerometer to show fore and aft G’S and lateral, or am I getting into to deep?

Whaaaat??? :astonished:
Yes, YOU ARE, at least for me!!! I do know how to drive my car, but that's enough for me, and I don't really like it. ROFLOL XD

bibre:

Whaaaat??? :astonished:
Yes, YOU ARE, at least for me!!! I do know how to drive my car, but that's enough for me, and I don't really like it. ROFLOL XD
[/quote]
Billy,
Come on you never had the thought of going full throttle through a turn or just put your foot to the floor to see how fast your car can go. LOL
I can understand, my wife road with me in one autocross and that was enough for her, but when we go to work the races...she loves it.

But as far as the acclorometer? A second board 19 led's and the acclorometer its self. But what would be the programming/sketch?

Hey Linc!

Come on you never had the thought of going full throttle through a turn or just put your foot to the floor to see how fast your car can go. LOL

Touché !!! XD

Not only had the thought, ... I did it many times, he, he! ]:smiley:

Many cars have nasty voltage spikes & stuff. I would put a transzorb across that pin as well.
You can expect 14.5V when the battery is charging.
Vout = Vin R2/(R1+R2)
You know you want Vout <=5V, Vin up to 14.5V, pick an R2 of say 6.8K and Solve for R1
Vout(R1 + R2) = Vin R2
VoutR1 + Vout R2 = VinR2
VoutR1 = (VinR2 - VoutR2) or (Vin-Vout)*R2
R1 = (Vin - Vout)R2/Vout
so (14.5 - 5)6800/5 = 12920
using a standard 15K:
14.5
6800/(6800+15000) = 4.55V
and if Vin was lower
12
6800/(6800+15000) = 3.74V so you get a good high over the expected Vin range.

Current draw, V=IR, so V/R = I
14.5/(6800+15000) = 0.66mA

CrossRoads:
Many cars have nasty voltage spikes & stuff. I would put a transzorb across that pin as well.
You can expect 14.5V when the battery is charging.
Vout = Vin R2/(R1+R2)
You know you want Vout <=5V, Vin up to 14.5V, pick an R2 of say 6.8K and Solve for R1
Vout(R1 + R2) = Vin R2
VoutR1 + Vout R2 = VinR2
VoutR1 = (VinR2 - VoutR2) or (Vin-Vout)*R2
R1 = (Vin - Vout)R2/Vout
so (14.5 - 5)6800/5 = 12920
using a standard 15K:
14.5
6800/(6800+15000) = 4.55V
and if Vin was lower
12
6800/(6800+15000) = 3.74V so you get a good high over the expected Vin range.

Current draw, V=IR, so V/R = I
14.5/(6800+15000) = 0.66mA

Thanks for the input but I am afraid that my translator has broken and all I got was in Greek LOL XD

Really, what I am tapping into is the stop lamp switch which is a normally open switch. So a voltage spike from the alternator is possible but not probable. And with am amperage draw of 3.5 amps for this particular application but I could see some where I could reach an amperage draw of 10 amps.

Alternators now a day are mostly PWM to keep a constant voltage in order to keep the spikes down for the already onboard computers.

spycatcher2k:
Here's the diagram :

I may be wrong, but in that scheme, if you measure the voltage over the Arduino input and the ground, it will be 7V, and I guess we don't want that. Therefore, I think the resistors should swap places. Correct?