How to use analog reading in array outside of the array.

I am trying these sensors and a library companied with these

So the example code will give me readings from 6 analog pins in array. I see these nicely on serial monitor.
I have got the hang of how to construct an array recently, but doing the opposite baffles me. Also am not able to understand the QTR library functions - can’t find good reference.

So I need to use these readings one by one to control different things. Like I have used to do with analog reads from photo cells and such - like this

int Pin0 = 0;     // the cell and 10K pulldown are connected to a0
int Read1;     // the analog reading from the sensor divider
int Pin1 = 1;
int Read2;
int Pin2 = 2;
int Read3;
int Pin3 = 3;
int Read4;
int Pin4 = 4;
int Read5;
void setup(void) {
  // We'll send debugging information via the Serial monitor
  Serial.begin(9600); 
Read1 = analogRead(Pin0);
Read2 = analogRead(Pin1); 
Read3 = analogRead(Pin2); 
Read4 = analogRead(Pin3);
Read5 = analogRead(Pin4);
 
  Serial.print("1=");
  Serial.println(Read1);
  delay(3000);
  Serial.print("2=");
  Serial.println(Read2);
  delay(3000);
  Serial.print("3=");
  Serial.println(Read3);
  delay(3000);
  Serial.print("4=");
  Serial.println(Read4);
  delay(3000);
  Serial.print("5=");
  Serial.println(Read5);
  delay(3000);
}

void loop(void) {
Read1 = analogRead(Pin0);
Read2 = analogRead(Pin1); 
Read3 = analogRead(Pin2); 
Read4 = analogRead(Pin3);
Read5 = analogRead(Pin4);
 
  Serial.print("1s=");
  Serial.println(Read1);
  delay(1000);
  Serial.print("2s=");
  Serial.println(Read2);
  delay(1000);
  Serial.print("3s=");
  Serial.println(Read3);
  delay(1000);
  Serial.print("4s=");
  Serial.println(Read4);
  delay(1000);
   Serial.print("5s=");
  Serial.println(Read5);
  delay(1000);
 
}

This is the example code coming with the QTR library:

#include <QTRSensors.h>

// This example is designed for use with six QTR-1A sensors or the first six sensors of a
// QTR-8A module.  These reflectance sensors should be connected to analog inputs 0 to 5.
// The QTR-8A's emitter control pin (LEDON) can optionally be connected to digital pin 2, 
// or you can leave it disconnected and change the EMITTER_PIN #define below from 2 to 
// QTR_NO_EMITTER_PIN.

// The setup phase of this example calibrates the sensor for ten seconds and turns on
// the LED built in to the Arduino on pin 13 while calibration is going on.
// During this phase, you should expose each reflectance sensor to the lightest and 
// darkest readings they will encounter.
// For example, if you are making a line follower, you should slide the sensors across the
// line during the calibration phase so that each sensor can get a reading of how dark the
// line is and how light the ground is.  Improper calibration will result in poor readings.
// If you want to skip the calibration phase, you can get the raw sensor readings
// (analog voltage readings from 0 to 1023) by calling qtra.read(sensorValues) instead of
// qtra.readLine(sensorValues).

// The main loop of the example reads the calibrated sensor values and uses them to
// estimate the position of a line.  You can test this by taping a piece of 3/4" black
// electrical tape to a piece of white paper and sliding the sensor across it.  It
// prints the sensor values to the serial monitor as numbers from 0 (maximum reflectance) 
// to 1000 (minimum reflectance) followed by the estimated location of the line as a number
// from 0 to 5000.  1000 means the line is directly under sensor 1, 2000 means directly
// under sensor 2, etc.  0 means the line is directly under sensor 0 or was last seen by
// sensor 0 before being lost.  5000 means the line is directly under sensor 5 or was
// last seen by sensor 5 before being lost.


#define NUM_SENSORS             6  // number of sensors used
#define NUM_SAMPLES_PER_SENSOR  4  // average 4 analog samples per sensor reading
#define EMITTER_PIN             2  // emitter is controlled by digital pin 2

// sensors 0 through 5 are connected to analog inputs 0 through 5, respectively
QTRSensorsAnalog qtra((unsigned char[]) {0, 1, 2, 3, 4, 5}, 
  NUM_SENSORS, NUM_SAMPLES_PER_SENSOR, EMITTER_PIN);
unsigned int sensorValues[NUM_SENSORS];


void setup()
{
  delay(500);
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);    // turn on Arduino's LED to indicate we are in calibration mode
  for (int i = 0; i < 400; i++)  // make the calibration take about 10 seconds
  {
    qtra.calibrate();       // reads all sensors 10 times at 2.5 ms per six sensors (i.e. ~25 ms per call)
  }
  digitalWrite(13, LOW);     // turn off Arduino's LED to indicate we are through with calibration

  // print the calibration minimum values measured when emitters were on
  Serial.begin(9600);
  for (int i = 0; i < NUM_SENSORS; i++)
  {
    Serial.print(qtra.calibratedMinimumOn[i]);
    Serial.print(' ');
  }
  Serial.println();
  
  // print the calibration maximum values measured when emitters were on
  for (int i = 0; i < NUM_SENSORS; i++)
  {
    Serial.print(qtra.calibratedMaximumOn[i]);
    Serial.print(' ');
  }
  Serial.println();
  Serial.println();
  delay(1000);
}


void loop()
{
  // read calibrated sensor values and obtain a measure of the line position from 0 to 5000
  // To get raw sensor values, call:
  //  qtra.read(sensorValues); instead of unsigned int position = qtra.readLine(sensorValues);
  unsigned int position = qtra.readLine(sensorValues);
  
  // print the sensor values as numbers from 0 to 1000, where 0 means maximum reflectance and
  // 1000 means minimum reflectance, followed by the line position
  for (unsigned char i = 0; i < NUM_SENSORS; i++)
  {
    Serial.print(sensorValues[i]);
    Serial.print('\t');
  }
  //Serial.println(); // uncomment this line if you are using raw values
  Serial.println(position); // comment this line out if you are using raw values
  
  delay(250);
}
int Pin0 = 0;     // the cell and 10K pulldown are connected to a0
int Read1;     // the analog reading from the sensor divider
int Pin1 = 1;
int Read2;
int Pin2 = 2;
int Read3;
int Pin3 = 3;
int Read4;
int Pin4 = 4;
int Read5;

I thought you said you understood how to create arrays. Apparently not.

I don’t understand what the problem is. The readLine() method takes an array as an argument, and populates the array.

I thought you said you understood how to create arrays. Apparently not.

Indeed, Sir? The problem is that I can not find a call similar to analogRead() with QTR library. I need to get readings from each single sensor and not any kind of array. Do I need the QTR library at all?

vanakaru: The problem is that I can not find a call similar to analogRead() with QTR library. I need to get readings from each single sensor and not any kind of array. Do I need the QTR library at all?

Have you found and run the examples that come with the QTR library? I'm struggling to understand what you're asking for that the examples don't already provide.

Yes, I do not see how to proceed from given examples. These examples read analog pins into array. I need these values out of the array. I fail to understand what is the Arduino's analogRead in QTR library. So if I would see how the example is done with just one sensor I could probably go on from there.

void read(unsigned int *sensorValues, unsigned char readMode = QTR_EMITTERS_ON) Reads the raw sensor values into an array

What's wrong with getting the readings into an array, and then using them individually?

I'm sorry, I really don't see any kind of problem here.

I do not know how to read the values in an array individually. How should I write the code if I need to use the values from one pin ONLY.

Looks to me from this snippet:

for (unsigned char i = 0; i < NUM_SENSORS; i++)
  {
    Serial.print(sensorValues[i]);
    Serial.print('\t');
  }

… that the readings are in an array called sensorValues, so if you want any one of them just do that with the index, eg sensorValues[2] or sensorValues[4] or whatever.

I do not know how to read the values in an array individually

int myInterestingValue = sensorValues [0]; Or whatever.

Got it!