0

I'm using this code i found on another project for gyrosensor.

gyrosensor code

The application will run. But I believe this code is doing something else.

What i want is, to be able to rotate the phone and it shows the degrees. So if i rotate the phone, it will show me rotating it by degrees.

But with this code, its in rad/s and I can't figure out how it works. If i move the phone really fast then it will start displaying like '1' or '2' on the x,y,z. But if i just move my phone regularly, it just stays at 0.

yup
  • 1

1 Answers1

0

Your used code only reads the raw gyrosensor data. That is only the force that is measured on the rotation axis. You should read the accelerator and the magnetic forces to get the rotation. The gyro only shows changes of the rotation.

You can use the SensorManager to calculate the rotation from the raw values. Get rotation and display in degrees

Community
  • 1
  • 1
Rocket
  • 1,030
  • 5
  • 24
  • When i implement that code from the other answers i run into some errors. here is a screen shot http://i.imgur.com/5mXDpho.png – yup Nov 20 '15 at 20:17
  • where should i put the Math.toDegrees()? right under the last line of code? – yup Nov 20 '15 at 20:18
  • Here is the full source code take a look: http://www.codingforandroid.com/2011/01/using-orientation-sensors-simple.html – Rocket Nov 20 '15 at 20:20