Reading a voltage from an LED

I am trying to use an Arduino Uno to read the voltages from LED’s on another PCB. I did not make the other PCB, nor do I have the code or schematic for it, but it is pretty simple. It has an array of 10 LED’s that flash. I am using a 1603 LCD display to convert the reading, like a flashing LED 10 to say “Level 10” on the display. I am using a series of IF statements and reading the LED voltage using an analog read function. Is this the correct way to go about it? It seems to be very buggy and gives me false readings. For example, when the first LED flashes, my LCD display reads Level 10 and then Level 1.

Here is my code.

#include <LiquidCrystal.h> // include the LCD library
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int LubPin1 = A1; //Lubentiometer input pin
int LubPin2 = A2; //Lubentiometer input pin
int LubPin3 = A3; //Lubentiometer input pin
int LubPin4 = A4; //Lubentiometer input pin

int LubValue1 = 1;
int LubValue2 = 2; // final display variable
int LubValue3 = 3;
int LubValue4 = 4;
const int threshold = 20;
//const int buttonPin = 5;     // the number of the pushbutton pin

void setup() {
  lcd.begin(16, 2); // lcd rows and columns
  lcd.begin(16, 2);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(" LED's ");
  lcd.setCursor(0,1);
  lcd.print("LED LEVEL READER");
 
  lcd.setCursor(0,0);
  for (char k=0;k<26;k++){             
    //    lcd.scrollDisplayLeft();
  delay(100);
  }
  lcd.clear();
  lcd.setCursor(0,0); 
  lcd.print("Activate Sensor");
  lcd.setCursor(0,1);
  lcd.print("---");
  delay(3500);
  lcd.clear();
  delay(500);
  lcd.setCursor(0,0);
  lcd.print("Press for result");
 // delay(2000);
 // lcd.clear();

}
void loop() {
// read then divide the input(max 1020 in this case) by 10
    LubValue1 = analogRead(LubPin1) / 10;
    LubValue2 = analogRead(LubPin2) / 10;
    LubValue3 = analogRead(LubPin3) / 10;
    LubValue4 = analogRead(LubPin4) / 10;

lcd.setCursor(0, 1);
if (LubValue1 > threshold)  {
lcd.print("LEVEL 1");
delay(10000);}
else {
  lcd.clear();
}

lcd.setCursor(0, 1);
if (LubValue2 > threshold) {
lcd.print("LEVEL 7");
delay(10000);}
else {
  lcd.clear();
}

lcd.setCursor(0, 1);
if (LubValue3 > threshold) {
lcd.print("Level 9");
delay(10000);}
else {
  lcd.clear();
}

lcd.setCursor(0, 1);
if (LubValue4 > threshold) {
lcd.print("LEVEL 10");
delay(10000);}
else {
  lcd.clear();  
}
}

This is actually a trickier task than it first appears. If the circuit you are testing is electrically separate from your arduino, then passive measurement of the voltage across the LED is not straight forward.

If you connect your arduino GND to the other circuits GND then you can measure the voltages at the cathode and the anode of the LED under scrutiny. Then use subtraction to determine the voltage across it.

It seems to be very buggy and gives me false readings. For example, when the first LED flashes, my LCD display reads Level 10 and then Level 1.

Any time the Arduino finds something interesting and executes one of you're if statements, it's only allowed to print it's findings, then it's forced to do absolutely nothing for 10 seconds. Almost like it's being punished. Poor thing, being held back like that and missing out on all the LED action.

You can't call delay() and expect to watch something that's flashing!!

Could the LEDs be PWMed? If so they could be flashing a lot faster than you think...

What's the supply voltage of the other board? Perhaps you can observe the logic signals driving the LEDs (ie before the series resistor/LED) using digitalRead () ?

Your taking an analog read of a voltage around 3 volts when it's on.. That's maybe a reading of 614ish? Could easier be lower depending on the voltage used to turn the led's on.. Next your dividing it by ten before comparing it to a threshold of only 20.. With noise between the 2 boards your probably going to read some errors..

Maybe take the readings and simply compare them to a threshold of 150 or so.. If you want to see what kind of noise is in your readings create another sketch that just takes analog readings and serial prints them.. Then you can pick a threshold that will definitely tell you if it's on or off..

I am assuming that the ground of the other board is connected to the arguing ground and also that the led's are grounded at all times and pulled high to light up??

dlloyd: Any time the Arduino finds something interesting and executes one of you're if statements, it's only allowed to print it's findings, then it's forced to do absolutely nothing for 10 seconds. Almost like it's being punished. Poor thing, being held back like that and missing out on all the LED action.

The way I see it, there are people in other parts of the world that don't even have access to an abacus. Wasting processing power like that is down right disrespectful. The OP should be ashamed of himself!

If you can have a common GND with the other board can't you detect the LED On/Off with Arduno digital pins? Much faster than using analogRead()

Also, and very important, if you switch analaogRead() from one pin to another pin you should discard the first reading on the new pin to allow the ADC time to settle. See the Atmel datasheet.

...R