Cheap and good way to feed 12v digital input

I want to feed the digital pin from 12v.
What will be the cheap and best way to drop it to 5V

  1. Voltage divider
  2. Tiny 7805 regulator

Or is there any other way..??

I do not want to use a RELAY..:frowning:

Can't get much cheaper than a voltage divider; just make sure that your 12V input really is 12. In case it can be a little high, you may want to choose resistors to drop it a little lower than 5V - it'll still register as high.

For extra protection you could connect a 5.1V Zener diode between the Arduino input and ground (as well as using the voltage divider). This should help protect the Arduino from any excess voltages or spikes.

Paul

wildbill:
Can't get much cheaper than a voltage divider; just make sure that your 12V input really is 12. In case it can be a little high, you may want to choose resistors to drop it a little lower than 5V - it'll still register as high.

A good point..
The 12V is not constant all the time.. It sometimes rises to 16V too..

So I guess, there is a problem with the voltage divider..:frowning:

The 12V is not constant all the time.. It sometimes rises to 16V too..

Another option is a resistor and a pair of [u]protection diodes[/u] (the 2nd schematic on that page). I'd use a larger resistor (at least 10K) and you can leave out D2 if you're sure the input will never go negative.

Or, you can also use a voltage divider with one or two "protection diodes". (That's the same protection circuit with a 2nd resistor in parallel with D2.)

A voltage regulator is designed for power, not data. It's not fast enough for normal digital data and it could potentially load-down a data line. It's just the part for this application.

I finally decided to use the 7805 SOT89 package, as I am working on SMD board and the space is a real issue.

I don't think a voltage regulator is the right application, as DVDdoug already told you. It's a shame that you didn't listen. Voltage regulators are designed to POWER something. They are never used to regulate the voltage on a data line. Good luck making that work.

Any SOT23 MOSFET could also have been used.

Use the 12-16V to drive an optoisolator, on the output side pull the open collector low on an arduino input with pullup resistor enabled.

CrossRoads:
Use the 12-16V to drive an optoisolator, on the output side pull the open collector low on an arduino input with pullup resistor enabled.

.... which will reverse the logic, but you can take care of that in code. If that's an issue, use an external pulldown to keep the logic the same way round.

A 4.5v ish zener diode and a zener should do the job...

Take a look at v-usb which uses a zener to knock the data lines down to 3v from 5v, the same can be applied here a couple (guessing 200 to 500) resistors.

How's this?

Joy:
I finally decided to use the 7805 SOT89 package, as I am working on SMD board and the space is a real issue.

Then you have made the wrong decision and made yourself look foolish.

As per CrossRoad's suggestion (several variations):

Voltage swing at Arduino input: 0 to 4.9V (see Fig. 6 here).

Xpendable:
I don't think a voltage regulator is the right application, as DVDdoug already told you. It's a shame that you didn't listen. Voltage regulators are designed to POWER something. They are never used to regulate the voltage on a data line. Good luck making that work.

Actually I am not using it to trigger any arduino pin.. I am using a 8 PIN PIC with a very tiny PCB.. Space is a real issue. So if I am using a SOT-89 7805 I do not require any other component.

I definitely agree that using an Optoisolator is the best option, but it requires many other components too and will occupy lil larger space than what the SOT-89 7805 will occupy.

Actually I am not using it to trigger any arduino pin..

So what are you using it for?

Cheap, good and small:
SOT-89 (7805): 1.6mm x 4.6mm, area 7.36mm2,
SOT-416 (DTC114W): 1.7mm x 0.9mm, area 1.53mm2, $0.20 each
I/O Connections: VIN 0-30V, OUT (inverted) connected to PIC input with Pull-up enabled.

Grumpy_Mike:

Actually I am not using it to trigger any arduino pin..

So what are you using it for?

I have mentioned it on my previous post. I am actually using it to trigger a SMD 8 Pin PIC Microcontoller..

The main target is to make the PCB as tiny as possible and making it cheap retaining the quality, as it will be mass produced..

dlloyd:
Cheap, good and small:
SOT-89 (7805): 1.6mm x 4.6mm, area 7.36mm2,
SOT-416 (DTC114W): 1.7mm x 0.9mm, area 1.53mm2, $0.20 each
I/O Connections: VIN 0-30V, OUT (inverted) connected to PIC input with Pull-up enabled.

I am unable to make out how will it work..
I went through the datasheet too, bu cant make out..It would be kind of you, if you can elaborate please..

Hint:
The 7805 has 3 terminals (INPUT, OUTPUT, GND).
The DTC114W has 3 terminals (IN, OUT, GND).