The Tilt Sensor basic tilt switch can easily be
used to detect orientation. Inside the can is a ball that make contact
with the pins when the case is upright. Tilt the case over and the ball
doesn't touch the pins, thus not making a connection.