qre1113 sensor

I have a qre1113 sensor to detect black and white colors, but when trying to measure distances instead of colors, I leave the code.

// code
int s1,s2,s3,s4,s5,s6,s7,s8;
int sb1,sb2,sb3,sb4,sb5,sb6,sb7,sb8;
void setup() {
Serial.begin(9600);
}

void loop() {
s1 = analogRead(A1);
s2 = analogRead(A2);
s3 = analogRead(A3);
s4 = analogRead(A4);
s5 = analogRead(A5);
s6 = analogRead(A6);
s7 = analogRead(A7);
s8 = analogRead(A8);

sb1 = map(s1, 0, 1023, 0, 255);
sb2 = map(s2, 0, 1023, 0, 255);
sb3 = map(s3, 0, 1023, 0, 255);
sb4 = map(s4, 0, 1023, 0, 255);
sb5 = map(s5, 0, 1023, 0, 255);
sb6 = map(s6, 0, 1023, 0, 255);
sb7 = map(s7, 0, 1023, 0, 255);
sb8 = map(s8, 0, 1023, 0, 255);

Serial.print(" A1=" );
Serial.print(sb1);
Serial.print(" A2=" );
Serial.print(sb2);
Serial.print(" A3=" );
Serial.print(sb3);
Serial.print(" A4=" );
Serial.print(sb4);
Serial.print(" A5=" );
Serial.print(sb5);
Serial.print(" A6=" );
Serial.print(sb6);
Serial.print(" A7=" );
Serial.print(sb7);
Serial.print(" A8=" );
Serial.print(sb8);

Serial.println("...");

delay(1000);
}

Yes, and? You would benefit by learning about arrays. We would all benifit if you were to read the "how to use the forum" stickies.

(deleted)

The QRE1113 is a very short range device - of the order of a few millimetres.

Because you have all those analogRead() statements but have not told us what they are for I wonder if your description of what you want to do is misleading.

And this sort of thing won't work properly

s1 = analogRead(A1);
  s2 = analogRead(A2);       
  s3 = analogRead(A3);

because the 2nd reading will be getting remnants of the 1st one and the 3rd will be getting remnants of the 2nd etc.

Do it like this

s1 = analogRead(A1);
s1 = analogRead(A1);
s2 = analogRead(A2);
s2 = analogRead(A2);       
s3 = analogRead(A3); 
s3 = analogRead(A3);

so that you read each pin twice and discard the first reading.

And, as mentioned elsewhere, learn about arrays.

...R