At the beginning of my code I start nine variables:
int16_t ax, ay, az;
int16_t gx, gy, gz;
int16_t xc, yc, zc;
Later on I collect the data from my gyro/accelerometer (the MPU6050):
accelgyro.getAcceleration(&ax, &ay, &az);
accelgyro.getRotation(&gx, &gy, &gz);
Now I would like to set the value of xc
to the sum of ax
and gx
.
Here is what I am currently using:
&xc == &ax & &gx;
So far this has not worked.
Try just xc = ax + gx;
== is for comparison. It returns true if the two things on either side are equal and false if not. = is for assigning a value to something. The & symbol is to get the memory address of a variable. If you're not trying to add the memory addresses then you don't want the &. In those function calls the function is expecting a pointer apparently so that's why the & is there. Enough can't be said for going through a quick basic C++ tutorial to pick stuff like this up. This will be a very frustrating experience otherwise.