Error compiling code for Capacitive Sensor - Array- Shift register -LEDs

Hi all helpfull people.

With my UNO I made a matrix of 10 capasitive sensors (dig.input pin2-12) associated with the analog pins as dig.output for 10 LEDs via a Shift register 74HC595.

I tested the shift reg. acc.to tutorial ShiftOut and it worked for 8 output.
Separatly I tested the capasitive pads with tutorial for this , whitch worked.
To shorten the code i implemented loop with array, and there starts the problem.
I have searched for tips and changed my code acc.to those, many times, but ends up with:

"CapSensor cant be used as a function" , "variable-sized object 'capSensor' may not be initialized", and finaly: "TEST_ShiftOut-IF-Array-_RETTET.ino: In function 'void loop()':
TEST_ShiftOut-IF-Array-_RETTET.ino:36:32: error: request for member 'capacitiveSensor' in 'array[T]', which is of non-class type 'int' ....

Here is the code that will not compile:

//  Name: TEST_ShiftOut-IF -> CapSensor m Array for tak 1-8 + 9-10
//****************************************************************
#include <CapacitiveSensor.h>
int latchPin = 17;  //Pin connected to ST_CP of 74HC595
int clockPin = 18;  //Pin connected to SH_CP of 74HC595
int dataPin = 19;   //Pin connected to DS of 74HC595
int array[10] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; //Array for dig.pinner IN from sensor.
int sensorValue[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //Array for values to check.
int threshold = 10000;
int TAK[8] = {1, 2, 4, 8, 16, 32, 64, 128}; //Writes to touched Shift-pin // line10
int T;
int capSensor(int x);
CapacitiveSensor capSensor3 = CapacitiveSensor(2, 3);  //capSensor3-12 brukes  void loop.
CapacitiveSensor capSensor4 = CapacitiveSensor(2, 4);
CapacitiveSensor capSensor5 = CapacitiveSensor(2, 5);
CapacitiveSensor capSensor6 = CapacitiveSensor(2, 6);
CapacitiveSensor capSensor7 = CapacitiveSensor(2, 7);
CapacitiveSensor capSensor8 = CapacitiveSensor(2, 8);
CapacitiveSensor capSensor9 = CapacitiveSensor(2, 9);
CapacitiveSensor capSensor10 = CapacitiveSensor(2, 10);   //line20
CapacitiveSensor capSensor11 = CapacitiveSensor(2, 11);
CapacitiveSensor capSensor12 = CapacitiveSensor(2, 12);
void setup() {
  for (int x = 0; x < 10;) {
    array[x] = capSensor(x + 3);
  }
  pinMode(latchPin, OUTPUT);  //Output for shift register
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  Serial.begin(9600);
}  //linje30

void loop() {
  for (int x = 3; x < 13;) { //Checks proximity to "capSensor3-12".
    T = x - 3;
    array[T] = capSensor(x);                                        //Corrected
    long sensorValue = array[T].capacitiveSensor(2000); //LINE36- ERROR
    Serial.print ("SensorValue=");
    Serial.print (sensorValue);
    Serial.print ("  TAK=");
    Serial.println(TAK[T]);
    delay(100);
    //linje40
    if ( sensorValue > threshold ) {  //Lights LED if "SensorValue3-10" > threshold value.
      Serial.println("STORRE");
      digitalWrite(latchPin, LOW);  //LatchPin low so LEDs don't change while you're sending in bits.
      shiftOut(dataPin, clockPin, MSBFIRST, TAK[T]); // Shift out the bits.
      digitalWrite(latchPin, HIGH);  //Latch pin high so the LEDs will light up.
      delay(500);
    }
    else {
      digitalWrite(latchPin, LOW);
      shiftOut(dataPin, clockPin, MSBFIRST, 0);  // shift out the bits:
      digitalWrite(latchPin, HIGH);  //Do I need this to keep LEDS off ?
      delay(10);
    }
  }
  if ( sensorValue[11] > threshold )
  {
    digitalWrite(14, HIGH);
  }
  else {
    digitalWrite(14, LOW);
  }

  if ( sensorValue[12] > threshold )
  {
    digitalWrite(15, HIGH);
  }
  else {
    digitalWrite(15, LOW);
  }
}

Thanks for quick answer Delta_G.

Im new in C - programming and havent used array. I tried to follow receipt in "Learing - Reference" to make
array in line 7: "int array[10] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; //Array for dig.pins IN from sensor."

Sorry, - I thought that place no.10 in array contained "12" and that it represented dig.pin 12 ?

Which array declaration in which code line is wrong, and how should it be ?

It looks like you want to create an array of CapacitiveSensor sensor objects then call capacitiveSensor on each array element inside loop(). Try the following.

#include <CapacitiveSensor.h>

const int NUMCAPS = 10;       // # of sensors

// cap sensor objects
CapacitiveSensor capSensors[NUMCAPS] = {
  CapacitiveSensor(2, 3),
  CapacitiveSensor(2, 4),
  CapacitiveSensor(2, 5),
  CapacitiveSensor(2, 6),
  CapacitiveSensor(2, 7),
  CapacitiveSensor(2, 8),
  CapacitiveSensor(2, 9),
  CapacitiveSensor(2, 10),
  CapacitiveSensor(2, 11),
  CapacitiveSensor(2, 12)
};


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



}

void loop()
{

  // for each object 
  for (int i = 0; i < NUMCAPS; i++)
  {
    // print sensor output
    Serial.print(i);Serial.print(":  ");Serial.println(capSensors[i].capacitiveSensor(2000));
  }

}

Thanks to both of you.

Yes I wanted to make one array for the readings of sensors and an other for handling
these. The arrays should be called up by indexing in the for-loop to
compare sensorvalue with threshold.

It worked to make the array as Blue Eyes proposed.

Trond:
Im new in C - programming and havent used array. I tried to follow receipt in "Learing - Reference" to make
array in line 7: "int array[10] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; //Array for dig.pins IN from sensor."

Sorry, - I thought that place no.10 in array contained "12" and that it represented dig.pin 12 ?

In C++, arrays start at zero. The reason for this is that array indexing is treated as being an offset from the start of the array. The first element is at offset zero.

Sorry, PaulM, I meant "place no.9" (the last in array).