I have a 3 axis accelerometer and I want to smooth the outputs. Something is wrong in my code because all i'm getting on the serial monitor is 3 arbitrary characters.
//354 = 0m/s^2
//441 = 9.81m/s^2
const int numAxis = 3; //define the number of channels
const int inputs[numAxis] = {A1, A2, A3}; //define where each axis is
const int numReadings = 10; //define sample size
int xyz[numAxis]; //define array
int totals[numAxis]; //totals
int readings[numAxis]; //averages
void setup() {
Serial.begin(9600);
}
void loop() {
for(int index = 0; index < numReadings; index++){ //loop 10x
for(int axis = 0; axis < numAxis; axis++){ //read each axis
xyz[axis] = analogRead(inputs[axis]); //read current axis
}
totals[index] = xyz[numAxis] + totals[index]; //add to totals
}
readings[numAxis] = totals[numAxis] / numReadings; //divide by 10 to get average
String values = String(readings[0]) + ", " + String(readings[1]) + ", " + String(readings[2]);
Serial.println(values); //turn the array into a string and println
}
Where is the error in my logic?