AnalogRead results in different values when used in library [Solved]

Ok I am going to try to explain this the best that I can.

I am reading A0 and getting different values depending on if the read is done in a library or not.
I have a Uno and using Rev. 022

I have taken out irrelevant code.
I am using both interrupts (pin 2,3) just as a fyi.

At the start it seems like the library code needs to “settle”.
Any explanation to this would be great!

I can package all my code up and attach if need be.

Ecu Class Code:

#include "Ecu.h"
#include "WProgram.h"
Ecu::Ecu(void)
{
	accelInputPin      = A0;
        accelInput          = 0;
        pinMode(accelInputPin, INPUT);
}
void Ecu::SetValue(void)
{
	accelInput = analogRead(accelInputPin);
}

int Ecu::RetriveValue(void)
{
	return (accelInput);
}

int Ecu::DirectValue(void)
{
	return (analogRead(accelInputPin));
}

Code Main Program:

#include <Ecu.h>
#include <Streaming.h>

unsigned long timer;

Ecu myEcu;

void setup() 
{
   timer = millis();

  Serial.begin(9600);
}

void loop()
{
  if ((millis() - timer) > 1000)
  {
    outputSerialData();
  }
}

void outputSerialData()
{
  myEcu.SetValue();
  Serial << "AccelInput," << myEcu.RetriveValue() << endl;
  Serial << "AccelInputDirect," << myEcu.DirectValue() << endl;
  Serial << "AccelInputLocal," << analogRead(A0) << endl;

  timer = millis();
}

Serial Output:

AccelInput,886
AccelInputDirect,885
AccelInputLocal,699
AccelInput,720
AccelInputDirect,719
AccelInputLocal,699
AccelInput,680
AccelInputDirect,679
AccelInputLocal,699
AccelInput,671
AccelInputDirect,670
AccelInputLocal,699
AccelInput,668
AccelInputDirect,667
AccelInputLocal,699
AccelInput,668
AccelInputDirect,667
AccelInputLocal,699
AccelInput,668
AccelInputDirect,667
AccelInputLocal,699
AccelInput,668
AccelInputDirect,667
AccelInputLocal,699
AccelInput,668
AccelInputDirect,667
AccelInputLocal,699

Try...

Don't set an analog pin to INPUT with pinMode().

When doing the analogRead use "0", not "A0". A0 is a macro for using the pin as a digital I/O.

[quote author=James C4S link=topic=75192.msg567087#msg567087 date=1318439643] When doing the analogRead use "0", not "A0". A0 is a macro for using the pin as a digital I/O. [/quote] Wow ok that worked.

Changed accelInputPin = A0; to accelInputPin = 0;

Thanks very much for the help!