Question on Opto & LED indicator

I'm having a bit of a brain lapse I think, too much rainy weather and the end of the weekend.
I have a signal that I want to monitor for High & Low, and send the result via Opto to an Arduino.
I have a 24V source available (from a multi-use header) that I want to use as a pullup, the idea being that when the opto is driven, the output NPN pulls the Data line (D0 shown) low, and turns on the LED. Otherwise, resistor/divider R2/R4 keeps D0 at 5V.
However, since the LED has 24V on one side, and now ~0/5V on the other, it seems to me that it has either 19V (opto "Off") or 24V (opton "On"), so it will be on all the time.
What can I do to have the LED on when the NPN is on?

Think I got it - just added an LED for some isolation.
Now when the NPN is off, the collector is high, the LED is off, D2 lets signal D0 sit at 5V.
When the NPN is on, the collector is low, the LED is on, and D2 lets signal D0 go down to Vce + Vf.
Right choice of parts should let D0 pulled down enough for a valid Low into Arduino.

4N25 looks to have Vce of 0.5V
http://optoelectronics.liteon.com/upload/download/DS-70-99-0010/S_110_4N25(26).pdf

This diode has 0.2V Vf

So that should be well under the VIL max of 1.5V for a good low.

I was thinking 0.9V, so the diode is not as critical to meet 1.5V.

Clever solution.
Another option would be to put the LED in the primary circuit, as many relay boards do.
Leo..

Hi

Damn too late.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Can you please post a copy of your sketch, using code tags?
Please use code tags.. See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

What is your electronics, programming, arduino, hardware experience?
Is this a school/college/university project?

We are not here to provide you with an instant complete solution, we are here to provide guidance and advice.
This will help you develop your sketch, so that you understand how it works and you can debug any problems that may develop.

Isn't this forum great, even talking to yourself for 3 posts solves your problem, magic.
Then all it takes is a number of other members to pop up and confirm your musings.

Tom..... :slight_smile:

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Can you please post a copy of your sketch, using code tags?
Please use code tags.. See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Yes, my musing while waiting for some feedback, and waking up a little on a sleepy afternoon, and I had a solution.
And now I have 8 channels all laid out and routed.