how to connect 12 volt to digital input please help

hi all, i want to connect 12 volt to arduino digital input, i want to check if this input connected to 12 volt

i fount this site that's help in calcuate Resistor but i do not know what Resistor to connect to arduino to do this

thank you

It may also be interesting to calculate the example for an input of 24-30 volts and instead of reading the output digitally use one of the analog-pins and the analogRead()-function.

Problem with reading just HIGH or LOW digitally is that an arduino-pin will probably already see an HIGH if you read it digitally when it's connected to a voltage higher as 3-3.5 volts (datasheet will probably give you the number when it goes high).

Using the voltage divider calculated for 12 volts and connecting a 9-volt battery digitally would already trigger a HIGH.

Using an analog-pin and analogRead(), you could calculate what.... voltage is applied to VH in the example.

VO should be connected to the analogpin (or digital) of the arduino, VL should be connected to ground of the powersupply and ground of the arduino.

With 22000 ohm as R1, 4700 as R2 you could calculate voltages connected to VH up to 28 volt safely. Reading 12volt digitally... might result in a LOW using these values though.

hi all, thanks for replies, i will try it now, about protection, what you think if i use 7805 ? i have a lot of them? thank you

protection, what you think if i use 7805

And what protects the 05 then?

Sorry I read this as 7405, hex inverter with open collectors, not the power regulator which is totally the wrong thing to use.

hello, thank you Grumpy_Mike , KE7GKP for replies my project is car pc, and in this time i want to control shutdown and startup pc from arduino

i asked about 12v becouse i want to arduino check if AGC on, if on wait X min to start engine, after this run relay to connect 12 volt to pc power, and run another relay to (press power button on pc) to start pc,

i will try (6.8K = 6K8) (4.7K = 4K7) what do you think?

can i use any transisitor to do this? like 2n2222 i am very now to electorinc world but i want to learn with this project

thank you

hello, no sir i have your reply but i know the car alternate produce more than 12 volt, 14,5 or less, so i said i want to use 7805 for this, after your reply i have do some search and found that i can use some this like 4-PIN PHOTOTRANSISTOR OPTOCOUPLERS and i got this

can i ask you how to connect it? how i can use it with 12volt or more, and how to connect it to arduino? or if you have any advice how to do this,

thank you regards