How do I know the swing of the phone to control the turning of the object of the game

Hi All
I am a fresh man in unity. As title, I want create a object then it can turn when the device swing.

Get device rotation with: Input.acceleration

Then just rotate your object according to the values you get from the accelerometer.

Or you can use gyroscope, in case accelerometer data isn’t suitable for the thing you want to accomplish.