When you turn your phone sideways and the screen rotates, several tiny sensors are working together. Most modern phones use MEMS sensors, which are microscopic mechanical structures etched into silicon chips.
The accelerometer
An accelerometer measures changes in speed in three directions. It also detects gravity, which tells the phone which way is down, so it can estimate tilt when the phone is still.
The gyroscope
A gyroscope measures how fast the phone is rotating. Inside, tiny vibrating parts shift slightly when the device turns, which is detected through the Coriolis effect.
The magnetometer
A magnetometer senses the Earth’s magnetic field, acting as a digital compass.
Sensor fusion
No single sensor is perfect. Software combines their readings, often with filtering methods, so the phone can reliably know its orientation.