Am I doing this right? 12v -> 5v with pulldown?

This is a very crude chart, but I am curious if I have the concept and the parts correct. The install would be a little neater than this.

What I have is a signal that is either 12v or nothing. I need to reduce it to 5v to read with the arduino and add a pulldown to keep the value from floating.

Is this correct?

I've never seen that one before (for the purpose of reducing a voltage going to an input pin). If the output doesn't oscillate it should might work (with internal pull-up resistors turned on). Maybe you'll need a capacitor on the 5V side as well (see datasheet).

Why not just use a potentiometer (or 2 resistors) as a voltage divider? If you need protection against accidentally feeding 12V into the pin as well, add a 5.1V zener diode + series resistor as well.

Since "nothing" is undefined, this seems like a bad method to achieve what could be done with a simple voltage divider.

@ Arthur]Guy

My question to you is : Why are you using a 7805 ( a voltage regulator ) into a digital pin ? The moment in the code, you wrote digitalWrite ( from7805, LOW ); Well... the pin goes into "sink" mode and.... a short being created... :astonished:

NOT recommended...

My other question is : What are you trying to do ?

Not sure a 7805 is the right approach.. You could use a voltage divider as others have suggested. Or... I had a similar need in a project and decided to use an optocoupler (or optoisolator as it is also referred to). The concept is that you can have one circuit (eg 12v) trigger a response on another (eg Arduino input pin @ 5V) and have both circuits isolated (or not) as there is no electronic link between the two. For my purpose this was necessary. However, you dont have to isolate the circuits (eg power sources could share the same + and -). I used this Optocoupler 4N35 Response 3us Isolation 3.5kV - dipmicro electronics. The concept is that 5-19V on one side triggers an LED in the optocoupler that in turn triggers a low signal on the Arduino. On the Arduino side you wire 5V (from the Arduino) into the optocoupler and out to an input pin. Normally it would be HIGH. When 12V is provided to the other side of the optocoupler, it will bring the Arduino pin LOW. I have my circuit complete and will blog about in the next week or so. Check the link above as it's datasheet has an example. The circuit is very simple with just a few resistors and a diode. When I first built it, I was confused as it was pulling the Arduino input LOW, but this is how it is designed. Something that you can handle in the Sketch.

Would a FET with Gate connected to the input signal, Source/Drain being "high" and "input pin X" respectively (with appropriate pull-down resistor) do the same thing? Provides isolation between 12V channel and 5V logic, though the two systems will be linked via GND.

Not sure a 7805 is the right approach

I am sure it is defiantly the wrong approach.

I have seen beginners try this before and it stems from a misunderstanding of what you are doing and what voltage regulators do.
Depending on where the 12V is coming from you could use a potential divider perhaps with a 5.1V zenner diode to clamp the signal in case the voltage was slightly over 12V.

When using a voltage divider what is sent out when I remove the 12v source? I want to make sure that this does not become a floating input when there is no input.

My understanding of the 7805 was that it regulated 12v down to 5v which was all I needed. Apparently I was wrong.

For the guys asking what I am trying to do, I have a switch in my car that is fed with a 12v source (feeding it with 5v is not an option) and when pressed it sends 12v out that i want to send into the arduino to trigger various actions.

I want to make sure that this does not become a floating input when there is no input.

When no voltage is applied the lower leg of the potential divider acts as a pull down resistor and you get a logic zero. As you are in a car the voltage is often going to be much higher than 12V so use a zenner, also add a capacitor from input to ground to remove interference spikes.

@Arthur]Guy

For the guys asking what I am trying to do, I have a switch in my car that is fed with a 12v source (feeding it with 5v is not an option) and when pressed it sends 12v out that i want to send into the arduino to trigger various actions

Now I understand what you want do do.

1st. NO need for a 7805.
2nd. Use opto-coupler. So when a 12 V ( let call it HIGH ) and 0 V ( Let call it LOW ) Got me so far ?
Look into the 4N35 datasheet. 4N35 Datasheet catalog
Use a 910 ohm limiting resistor for the LED inside the opto-coupler.
12 V - --- 910 ohm ------- Opto LED ----- GND of the car. Got me so far ?

3rd. A resistor of 10 K -- +5 --- 10 K --- opto-transistor --- GND of the Arduino
And use a digitalRead ( optocouplerpin ); to read the info.

That is the simple idea I can think off.