analog serial read values are not equal

I have not used the Arduino in over 2 years and have forgotten a bunch of stuff I was wondering if someone could help me out. I have two analog sensors both the same connected to the appropriate analog pins. I am getting a read on the serial monitor and when i test the sensors the values are changing so i know the circuit is correct and everything is in the right place. I just have an issue with my code.

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue1 = analogRead(A0);

  // print out the value you read:
  Serial.println(sensorValue1);
   //Serial.print("val1 = " );
  Serial.print(sensorValue1);
  Serial.print(" ");

  delay(1000);        // delay in between reads for stability


   // read the input on analog pin 1:
  int sensorValue2 = analogRead(A1);

  // print out the value you read:
  Serial.println(sensorValue2);
  //Serial.print("val2 = " );
  Serial.print(sensorValue2);
  Serial.print(" ");
  delay(1000);        // delay in between reads for stability

 }

once i view this in the serial monitor it is not organized and the sensorvalue1 is skipping over to the next line. also the sensor values are not the same when the serial monitor starts. I would appreciate the help.

I've read here that best stable analog values are obtained by reading the analog pin twice and using the second read.

Serial.print("sensorValue1");
   //Serial.print("val1 = " );
  Serial.print(sensorValue1);

Replace these line it must work

Hi, what are your sensors?
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?
When you say;

once i view this in the serial monitor it is not organized and the sensorvalue1 is skipping over to the next line

Change;

Serial.print(" ");

to

Serial.println(" ");

in both lines.
println works at the end of the line you want printed, that is inserts a (return/linefeed).
Tom...hope it works... :slight_smile:

Uncompiled, untested

void setup() 
{
  Serial.begin(9600);
}

void loop() 
{
  for (int i = 0; i < 2; i++)
  {
    int sensorValue = analogRead(i);
    //sensorValue = analogRead(i);  // uncomment this line if things are still unstable
    char buffer [20];
    sprintf ("Val%d = %d", i, sensorValue);
    Serial.println (buffer);
    delay(1000);
  }  
 }