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?


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

  • \$\begingroup\$ Can you add schematic for clarification? \$\endgroup\$ Nov 8, 2014 at 0:59

2 Answers 2


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.


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/

  • \$\begingroup\$ wont the value read at A0 will always be the same? Since V+ is referred? \$\endgroup\$
    – User323693
    Aug 4, 2016 at 12:27

You could use a photoresistor.

           PhotoR     10K
 +5    o---/\/\/--.--/\/\/---o GND
 Pin 0 o-----------


  • \$\begingroup\$ okay, but, what if there're pretty many LEDs and they're very close each other? how can I get which LED is lighting? \$\endgroup\$ Nov 6, 2014 at 3:19
  • \$\begingroup\$ If they're on the same wire, if one lights the others should too.. \$\endgroup\$
    – hanoo
    Nov 6, 2014 at 3:23
  • \$\begingroup\$ You can mesure the voltage of the circuit using a voltage divider to know if the battery is good enouth. \$\endgroup\$
    – hanoo
    Nov 6, 2014 at 3:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.