# Reading 24V with arduino pin

Discussion in 'General Electronics Chat' started by jeffjohnvol, Mar 26, 2013.

1. ### jeffjohnvol Thread Starter Member

Oct 15, 2008
27
0
I have a switch that has 24 Volts that I need to feed into an Arduino. I also need an LED to show the status of the 24v signal. Will the attached circuit do the job, or is there an easier way to do it?

File size:
160.5 KB
Views:
551
2. ### BillB3857 AAC Fanatic!

Feb 28, 2009
2,493
389
Just two resistors as a voltage divider would do the 24v to 5v conversion for you. Standard LED with series resistor could monitor the 24V line.

3. ### jeffjohnvol Thread Starter Member

Oct 15, 2008
27
0
Yes. I thought about the resistor divider of 4.8K and 1K, but then when I put the LED circuit in parallel, I was concerned about a voltage drop.

I suppose if I put the LED in the series circuit and assume a 0.7v drop, it could work....

4. ### BillB3857 AAC Fanatic!

Feb 28, 2009
2,493
389
Make two separate circuits. The 4.8K/1k for the 24/5v conversion. Then I would use a 1k in series with the LED and connect it to the 24V line and ground for a simple indicator. On second thought, you may want to check the values you suggest for the 24v/5v divider circuit. I think with the values given, you will come up short for the 5v.

5. ### jeffjohnvol Thread Starter Member

Oct 15, 2008
27
0
Bill, yes, you are correct. They should be ~3.8 and 1 for a total of 4.8. My bad.

Though, I'm sort of thinking all in series of LED, 1K, 280 with the pickup to the uP between the the 2 resistors. That would save me a resistor and some soldering.

6. ### BillB3857 AAC Fanatic!

Feb 28, 2009
2,493
389
LED cathode to ground. 1k resistor to LED anode. 5K resistor in series to 1k to 24v. Take 5v from junction of 5k and 1k.

7. ### ScottWang Moderator

Aug 23, 2012
6,763
1,047

• ###### 24VSwto5V-Arduino.gif
File size:
3.5 KB
Views:
1,787
acandela and absf like this.
8. ### jeffjohnvol Thread Starter Member

Oct 15, 2008
27
0
Ah, okay. That makes sense. Thanks!

And Scott, thanks for the drawing. That would be what I would do if it were a permanent installation, but this will just be a breadboard for 2 days of testing. Thanks to all that replied!

9. ### philraf New Member

Feb 25, 2014
1
0
Scott,

I have the same need (24 VDC to Arduino), and came across your post. I was planning to use a simple two-resistor voltage divider circuit, but will go with your more complex approach if it is better.

I don't really understand the purpose of the Zener diode and the capacitor. Are they to protect against surges?

Also, I am perplexed by the resistances. If R2 is 330 ohms, doesn't R1 have to be around 1220 ohms to result in a 5.1V signal for the Arduino?

Hoping to be enlightened ...

Phil

Oct 15, 2008
27
0
11. ### ScottWang Moderator

Aug 23, 2012
6,763
1,047
You should know more about the zener.
The Equivalent Circuit of Zener diode Using Diode and LED Protection.

The capacitor will be about 47~220uF, the output of this kind of simple regular will more easier to affected by the load, so using a capacitor to discharge for the load, and making the output more stable.

The output will be fixed under 5.1V,
V_zener = 24V-5.1V = 18.9V,
I_zener = 10~50mA, if the current too less then the output voltage will be unstable.
I_LED = (5.1V-2V)/330Ω = 9.4mA, for the life of parts that you can choosing the current about 8mA.

You can calculate how much current the load can get.

12. ### BobTPH Senior Member

Jun 5, 2013
1,949
540
There seem to be 2 different kind of posters here answering 2 different questions. One seems to think the 5V for the Arduino is to power the Aduino. The others seem to think the 5V is just a signal as an input to the Arduino.

So, OP, which is it?

Bob