I have a project that is using a grounding signal to trigger a digital input, but I also need an automotive 12v signal to trigger the same input wire as if it were being grounded. It doesn't need to necessarily need to be the same digital input pin, but the signal will be coming in on the same wire. So my logic table would be something like:
voltage at digital pin
I am using a 7805 to convert the automotive 12v into 5v for the 328p pro mini 5v 16mhz Arduino. Does someone have an idea of how to best design a circuit to do this?
I suggest to measure the voltage with a analog pin and decide in software what the logic will be.
If you already use a internal voltage reference, then you can use that or else use the default 5V as voltage reference.
A voltage divider is two resistors. With R1 = 22k and R2 = 10k, you can measure up to 16V. You can increase the values for more safety. Up to 220k and 100k should still work.
A third large resistor can be used to pull the signal towards 5V when nothing is connected. You will not be able to check if the signal is floating or 5V. You need a second (digital) pin to test if the input is really floating.
Other possibilities are using two inputs with two voltage dividers, or a single digital input with extra hardware. With a analog input, you can make the decisions in software.
Hi @Koepel - just that the car environment has a LOT of interference going on, and a high impedance input will be more susceptible to picking it up. Of course I agree you need to protect the arduino input.
It's not clear from your post if you know how to wire the relay.
Your wording suggests not.
If what you are saying is you need a TTL LOW (0V) input to a 5V digital circuit
to be triggered by a 12V relay, then of course the contacts of the relay would
have COM tied to the 5V GND and the N.O. (Normally Open) contact tied to
the 5V input that you want to ground. When the relay engages, the contacts
close connecting the input to GND. There should be no issue with connecting
a high impedance TTL/MOS input to GND. There will of course be some
contact bounce which can be suppressed by adding a 1k pullup to 5V connected
to a .1uF to .47uF cap to GND. The N.O. contact would connect to the junction of
the resistor and cap and from there to the digital input. Steady state of the input
would be High until the contacts close shorting it to GND but the added resistor
and cap should suppress the bounce.