But even if it converts a double value to a integer value, it should be at most off by 1 right?
I turned the gyro 90 degs, then turned back to origin, but the value says -9.
Also, i tried that i need to rotate it a lot past the origin to let the gyro change value(so i turned it 90 degrees and turned back to the origin and try turning it more past the origin)
Well i’m not a C/C++ expert but double is stored as a 64-bit value with the sign[bit 63] ,exponent[next lower 11-bits], and mantissa[lowest 52 bits]. %d expects a 32-bit. So printf may get the sign, exponent and some mantissa or just the lower mantissa. BTW, casting to an int may also work so: printf(“gyro=%d”,(int)(gyro.get_value()));
Also, the API says the value of the gyro is 10x the degrees of rotation. So 90 degrees would be 900 counts back. So 9 would be about 1 degree. Maybe that is due to drift. I don’t have a feel for how much drift there is b/c I have not used the gyro yet.
Initializes a gyroscope on the given port. If the given port has not previously been configured as a gyro, then this function starts a 1 second calibration period.
Are you waiting 1 second in initialize() after you instance the gyro?