Detect voltage by arduino

arduino

I've wired simple circuit with 9V battery, red LED, 10K resistor to turn the light on.

And I'd like to know if the LED is lighting or not using arduino.

I simply wired Arduino's A0 pin and LED's + lead. Next, if I get value from A0 using analogRead() function, it returns 0 always. If I just read from A0 without wire, it returns random values(I don't know it's random or not, anyway, it seems to be irregular).

Question: How can I know external circuit's LED is lighting or not using Arduino?

PLUS

the question is related with this question

I've tested following schematic(sorry for its poor drawing)

4 digits display ----- 4N35(PIN 1)
           ㄴ---------- 4N35(PIN 2)

ARDUINO 5V ----------- 4N35(PIN 5)
        GND ---------- 4N35(PIN 4)
        A0 ----------- 4N35(PIN 4) <--- This is the goal

If I place LEDs for each side, it works well.

The problem is, the voltage I've measure from 4 digits display is too low as around 0.14.
So, it may be the reason 4N35 doesn't emit any signal I think(If I turned the power on of portable range, Arduino side LED is turned on for a moment).

Okay, Question again please !!!
I'd like to know the state of portable range and my trying is figuring out which LED is lighting from the 4 digits display. But, 4N35 could not catch its voltage(not sure tho).
How can I do this? Any comment will be helpful.

4 digits display with 6 pins
portable range
portable range control part
portable range control part 2

Best Answer

I am assuming you are going to simply measure the voltage drop across the LED and use that to determine if the LED is on, this will work but you will need a couple of extra components, you can damage your arduino if you feed in a voltage over 5V.

schematic

simulate this circuit – Schematic created using CircuitLab

In the above R1 and R2 form a voltage divider to reduce the voltage on the A0 pin of your arduino. We can calculate the maximum voltage you can use to safely stay under 5V on A0:

Vmax = 5.0 / (R2 / (R1 + R2))
     = 5.0 / (47000 / (100000 + 47000))
     = 15.6V

Finally read the value of A0 in your arduino code and use the following formula to convert that value into a voltage:

float r1 = 100000;
float r2 = 47000;

float vRaw = (analogRead(0) * 5.0) / 1024.0;
float vDrop = vRaw / (r2 / (r1 + r2));

Depending on the accuracy needed you may need to mess with the 5V value above and adjust r1/r2 to a measured value (depending on accuracy of the resistors you are using).

For a complete example see https://www.udemy.com/blog/arduino-voltmeter/