The 35-764 Tilt Sensor (non-mercury, 1/2A, 15 degrees) is a basic tilt switch that can easily be used to detect orientation.
Internal metal ball side the can makes contact with the pins when the case is upright. Tilt the case over and the balls don't touch, thus not making a connection.