Forgive me if this is off-topic. I haven't been very successful in my search attempts. I keep coming up with how to detect orientation programatically, and that's not what I'm after. What I'm looking for is more of a hardware/electrical engineering question.
How do tablets detect orientation of the tablet? Some can automatically switch from landscape to portrait when the screen is tilted a certain way, for example. What hardware is used to detect this, and how does it work?