need to sense whether there is voltage (12V) in a branch of my circuit

I have a switch circuit on a 12V (runny from car battery) branch of my circuit. I need to use the Arduino Digital input to sense whether the switch has been activated. I need to reduce the 12V to 5V at 40mA max (I think) I'm not try to measure the voltage just whether it is on or off. I need to know what components i need to wire it up. Would appreciate a wiring diagram if possible.

Thanks

George

A simple voltage divider is all that is needed. Voltage divider - Wikipedia

Thanks for the quick reply, any chance you could help me size the parts. I would really appreciate it.

Sorry i'm a newb

George

12V-R1-R2-Gnd. R1/R2 junction to arduino input.

12V-20K-10K-Gnd = 4V.
Then if 12 should go up to 15, output will only be 5V still.

Make sure to put a good diode across that motor, at the motor, as well. Anode to ground, cathode to the switch.

Thanks for the info

George

The motor is an inductive load. This raises the chances to fry your Arduino when switching the motor off. I would decouple it with an opto coupler.

now i'm really confused. Just to be clear the motor is a 12V Motor with a max amp draw of 400A. The motor is existing and i can really do much as the motor is concerned.

Putting a diode across the motor as suggested by CrossRoads will fix that. Alternatively, increase the resistor values to 200k and 100k, or even higher. This will limit the current going in to the protection diode on the Arduino input to a safe value.

geostu34:
now i'm really confused. Just to be clear the motor is a 12V Motor with a max amp draw of 400A. The motor is existing and i can really do much as the motor is concerned.

400A, really? I would love to see a picture of that motor. :wink:

Must have 1 heck of a generator in the car!

Maybe it's the starter motor?

A pullup on the arduino and a diode with cathode side to the motor and anode to the digital pin will provide a logic 0 when the motor isn't powered and a safe level logic 1 when it is. He is only after a quanitative value not a qualitative one. Motor powered arduino sees its logic supply, not powered it sees ~.538V.

You seem to assume that the positive line will always have a voltage >= 0V. This is not necessarily true since the motor is an inductive load. If for whatever reason a transient <0V is created this will fry the Arduino.

@Udo Klein
He's already been instructed to intall a flyback diode across the motor.