In a webpage you can access the Gyroscope using DeviceMotionEvent
.
simply check if that even exists prior to use it as plenty of mobiles do not allow or do not have such feature.
a good idea on how to start might be an old post from Peter's blog.
There's also some javascript libraries such as gyro.js that you might try.