Hello!
I am writing a program that will read&store analog values into a multi-dimensional array on an ArduinoMega.
I will be reading from this array as well to display onto an LCD, i have not written this function yet.
I dont have too much experience coding c/c++ so I am trying to figure out of my logic of accessing the array is correct.
Here is what my code currently is:
// Make a Multi-demensional Array!
// rawData[3][3] = { {V1,C1,T1},
// {V2,C2,T2},
// {V3,C3,T3} }
int rawData[3][3];
void setup() {
//initialize the Storage arrays for reading data
}
void loop() {
int getSensorData() {
//Nested for Loop, going to go across
int k = 0; //count for looping through analog pins
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
rawData[i][j] = analogRead(k);
k++;
}
}
}
}
I currently have rawData[3][3] being initialized outside of void setup(), I was reading that online you need to initialize outside of the main functions for it to be global.
I was thinking that there was maybe someway for me to pass the rawData into the getSensorData() function, but i just dont know.
Any help on general programming structure here would be great.
Thank you in advance.