I'm trying to get angles from accelerometer/gyroscope and i'm recieving float numbers from that sensor via bluetooth(Serial1) between +1 and -1. I want to get angle from that numbers so i tried using asin() function and it always returns number that i put in instead of radians.
jremington:
asin(x) ~ x (in radians, for small x).
Same for sin(x).
Sin of an angle is always between +1 and -1. arcsin uses sin of an angle and converts it in in an angle so it alwas uses small numbers. And in a manual of math.h it says that error occurs when number is between +1 and -1. How can I not use small numbers?
int i;
float x;
Serial.begin(9600);
for (i=0; i<10; i++) {
x = i/10.;
Serial.print("x = ");
Serial.print(x);
Serial.print(" asin(x) = ");
Serial.println(asin(x));
}
}
void loop(){
}
Ooooh, thanks, I see now what you meant by small numbers, I'm getting radians now with that program, and my program. I'm just convert that to angles now.
aarg:
The answer is in reply #7.
Did you perhaps mean: if (x > -1 and x <1)?
I've edited my code, I made mistakes. Serial.parseFloat returned 0 when it should return 1, so I used Serial.parseInt() to detect 1. I got an answer to my question, thanks for your help anyway .