Hello
I'm trying to average reading from MPU6050, but with floats.
Thats my Code:
#include<Wire.h>
const int MPU_addr = 0x68;
int16_t ax, ay, az;
long xSum;
long ySum;
long zSum;
long ReadingNo;
float axT, ayT, azT;
float aT[3];
void setup() {
Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
Serial.begin(57600);
ReadingNo = 0;
}
void loop() {
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr, 6, true); // request a total of 14 registers
ax = Wire.read() << 8 | Wire.read();
ay = Wire.read() << 8 | Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
az = Wire.read() << 8 | Wire.read();
xSum += ax;
ySum += ay;
zSum += az;
ReadingNo++;
delay(5);
if (ReadingNo >= 100) {
axT = (float)xSum / ReadingNo.0;
ayT = (float)ySum / ReadingNo.0;
azT = (float)zSum / ReadingNo.0;
aT[] = {axT, ayT, azT};
ReadingNo = 0;
}
}
And there i get "expected ';' before numeric constant" in lines with axT=, ayT= and azT=.
When I change that into:
axT = (xSum / ReadingNo.0);
ayT = (ySum / ReadingNo.0);
azT = (zSum / ReadingNo.0);
Error is "expected ')' before numeric constant". What should I change to make it work?