Read a 12V connected push button state

I need to "read" the state of a push button connected between +12V and GND using an arduino.
I made a simplyfied scheme. I can access switch terminals only (and the arduino side as well). As I can see, is a Pullup configurations and i'm not sure i can connect it directly to arduino digital pin.

I'm not much into electronics and i really need your help.

Thank you in advance

G.

Are you allowed to place a resistor across the switch ?

Is the Arduino GND the same as 12V GND.
Yes it is.

Hi @aniaclug ,
try this way:

d56bbf8daf60f2102b6003a935757d2ea3783661_2_489x500

I'm little confused.
The bottomleft of the scratch you modified from mine is 12V or GND?

Yes I can but i don't know how if it would change in any way the pushbutton logic (i mean, the button is somewhere connected to the car "computer" and is used by the car to select one of the gears (DNR).
I dont have any other info.
The oly thing i know is that Voltage between the pin and ground is 12V and current is 1.25mA (thus the 9,6KOhm equivalent resistor). The pushbutton simply shortcircuits pin to ground (so the scheme i posted).

I would use 18K for the upper resistor and 10k for the lower, the junction voltage will be about 4.3V and the 18k will protect the input pin from 12V in case of a circuit fault, the 12V - (ground) must be connected to Arduino - (GND).

The upper Resistor is not under my control

If you add a 2.2k resistor in parallel with the switch, what voltage appears across the switch ?

with a resistor as partitor, I would close the circuit and it would act as closing the switch, isn't it?

have to test, tomorrow (now is 1am here) :slight_smile:

Make the lower R 4.7k, the junction voltage will be about 3.9V.
4.7 / (4.7 + 9.6) * 12 = 3.94V.

R3 and R1 in series protects input pin from 12V in case of circuit fault (loss of ground connection).
New-Project(1)

1 Like

A reliable/regulated 5volt supply (7805) must be connected to the 5volt pin,
not to the V-in pin, which need 6volt minimum.

The question mark in post#1 could be a (1N4148/1N4004) diode, with cathode (ring) connected to the switch. With internal pull up of the pin enabled with pinMode(pin, INPUT_PULLUP);
Leo..

1 Like

I was thinking analog input, so like this?
New-Project(2)

2 Likes

Yes.
The switch can pull the pin to ground,
but the diode prevents 12volt to flow into the pin.
Leo..

1 Like

Thank you all. I did not consider the diode but is the solution. Now i go with the second part of my problem and a thought about voltage regulators

Here the second picture

First the regulator: I'm using a linear regulator. The arduino stuff, with rf24L01+, will be part of a party of three iot objects and wants c.a. 100mA (75 measured as peak) even considering peaks . This project will be boxed and i'm concerned about getting too hot. So i moved to a 7808 to have (14-8)*100=600mW (the car battry can deliver up to 14 volts) and use the internal regulator to dissipate the remaining (8-5)*100=300mW. Is that wise? Or i can just use a 7805 to do the dirty job? Or maybe i should move to a buck converter (but i read they make a lot of noise and i'm not sure if it will interfere with my RF)? And can I use ceramic capacoitors or i must use electrolitics ones for the regulator? (I supposed 220nF on input and 100nF on output)

Second part:
As you can see i want also act as the pushbutton using arduino pin, so i put a NPN 2N2222 (or a SS8050?) transistor, with a 96K resistor on the base, connected to another pin.

Is that correct?
My idea is to raise the pin level when i want to shortcircuit pushbutton pins by means of the tansistor saturation so that Collector and Emitter are "shorted".

Thank you in advance for all the help

P. S.
What are you all using to draw this very nice schemes? :slight_smile:

Hi
I wrote 12V GND to emphasize that it is the GND of the 12V

1 Like

1 Like

Sorry, i'm not sure to understand. This circuit should be used for "intercept" pushbutton? If yes, i don't get how it should work

Ah!

I was just providing a more "durable" circuit to go in the question-mark on your original diagram to protect against voltages which might occur in an automotive environment and set the threshold level at half of 12 V rather than 1.8 V with the single diode.