Help using Arduino to read voltage.

I must have something wired wrong or something. I don't understand what I'm doing wrong.

I have a Espar heater control unit and I'm trying to use an uno to read the heater control's green led voltage.

It should be so incredibly simple. :'(

I want to use the led's voltage as sensor input for a project I'm working on.

Please take a look at this picture:


I'm only using 2 wires. I have one wire soldered to the anode side of an led and another wire soldered to the cathode side.

So, In the picture above...

I have the Anode wire connected to my multimeter's red lead and the Cathode wire connected to my multimeter's black lead.

It works exactly as it should and reports about 2v (1.92v exactly) which is exactly right for a green led.

But for what ever stupid reason (I'm sure it's something I'm doing that is super stupid) I can not do the same thing with my uno.

here is the super simple sketch I'm using:

const byte EsparAnalogInputPin   = A0;  // Arduino Analog Espar   Sensor Input Pin
int EsparDigiMaxLED;                    // Espar Digi Max LED's     voltage represented as 1023 degrees of resolution.

void setup() {

  Serial.begin (9600);
  pinMode (EsparAnalogInputPin, OUTPUT);

void loop() {

  //check the green On/Off LED Status on the Espar DigiMax Controller.

  EsparDigiMaxLED = analogRead (EsparAnalogInputPin);                 // Sample Espar Digi Max LED's voltage with 1023 degrees of resolution.

  Serial.print ("Espar DigiMax LED voltage is "); Serial.print (EsparDigiMaxLED * (5.0 / 1023.0)); Serial.println ("v");

I have the cathode wire going into the uno's GND and I have the anode wire going into A0 which I am using as sensor input.

Here is the output from the "Serial Monitor" window:

"Espar DigiMax LED voltage is 0.10v"

Huh? What? It's only reading 1/10th of one volt?!?

Also, and most disturbing is the fact that it is forcing the Espar green led to turn off!!

I don't have any shields hooked up and I've tried 2 uno's 1 mega, and a micro. All of them do the same. Please tell me what stupid thing I'm doing wrong? I'm sure it's something super simple and super stupid of me.

Why does a multimeter work as expected but not the uno?

Would somebody tell me what I'm doing wrong?


I found the problem and yes it was incredibly stupid.

I posted in the General Electronics sub forum because I thought I had a General Electronic problem. Example, I didn't know my anode from my cathode.

But it turned out the problem was my incredibly bad programing skills.

"pinMode (EsparAnalogInputPin, OUTPUT);"

I at least found the problem because I named my variable a very long yet descriptive name.

I guess that explains why the green light was being forced off. Luckily I didn't fry my controll unit.

You don't need to pinMode an analog input pin, analogRead() does it automagically.

You should be measuring voltages relative to the equipment ground - that LED may be running from a 12V rail or something. Unless your Arduino is going to run from an isolated power supply this will matter.