Hello,
I'm trying to read some data for an acceleometer to get the vertical acceleration of an object in movement.
The problem is : when I do the following math operation, Arduino answer : "invalid type argument of unary '*' (have int)" : acarre = (float(ax)*sin(PI-alpha)*9.81/16384)**2 + (float(ay)*sin(PI-beta)*9.81/16384)**2 + (float(az)*cos(PI-gamma)*9.81/16384)**2;
I tried to change the type of variable, without success.
If you can explain where do the problem com from, that's nice !
Here is the code :
float verticalAcceleration (){ //renvoie l'accélération verticale
// Mesure des angles à l'aide du flitre complémentaire :
accel.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
alpha = 0.98*(alpha+float(gx)0.01/131) + 0.02(acos(ax/16384));
beta = 0.98*(beta+float(gy)0.01/131) + 0.02(acos(ay/16384));
gamma = 0.98*(gamma+float(gz)0.01/131) + 0.02(acos(az/16384));
// Calcul de l'accélération suivant z :
float a, acarre;
acarre = (float(ax)*sin(PI-alpha)*9.81/16384)**2 + (float(ay)*sin(PI-beta)*9.81/16384)**2 + (float(az)*cos(PI-gamma)*9.81/16384)**2;
a = sqrt(acarre) - 9.81;
return(a);
}