Ok I will stick with
const int numPorts=2;
I've cut the code down to one function and one call in set up and nothing in loop()
to keep it simple.
It may now be more a case of me not understanding function calls properly?
we now have
//-----------------
//set up the global variables
const int numReadings =10;
const int numPorts =2;
long numberofReadings=numReadings;
int readings[numReadings][numPorts]; // the readings from the analog input ports
int readIndex[numPorts];// the index of the current reading
float total[numPorts]; // the running totals for each port
float average[numPorts]; // the average for each port
void setup() {
// initialize serial:
Serial.begin(9600);
analogReference(EXTERNAL);
InitArray(readings,numReadings,numPorts); //call function to pre-fill the arrays
}
void loop() {
}
void InitArray(int readings[][numPorts],numReadings,numPorts){
// initialize all the readings to an initial read value from each port
for (int j=0; j< numPorts; j++){
int initReading=analogRead(j);
for (int i = 0; i < numReadings; i++) readings[i][j] = initReading;
total[j]=numberofReadings*initReading;
average[j]=initReading;
}
}
and Errors:
Func9_2_dimensional_array:7: error: 'numPorts' was not declared in this scope
Func9_2_dimensional_array:7: error: 'numReadings' has not been declared
Func9_2_dimensional_array:7: error: 'numPorts' has not been declared
Func9_2_dimensional_array.ino: In function 'void setup()':
Func9_2_dimensional_array:17: error: invalid conversion from 'int (*)[2]' to 'int'
Func9_2_dimensional_array:7: error: too many arguments to function 'void InitArray(int, int)'
Func9_2_dimensional_array:17: error: at this point in file
Func9_2_dimensional_array.ino: At global scope:
Func9_2_dimensional_array:22: error: 'numReadings' is not a type
Func9_2_dimensional_array:22: error: 'numPorts' is not a type