There are plenty of commercial options for this type of switch but for quick prototyping (or hobby projects), this worked great. Best of all it was made from stuff laying around in about 10 minutes. 8 minutes to find stuff. 2 minutes to assemble. Can't beat that!
This was interfaced into a PLC (Programmable Logic Controller). The only problems I ran into was the tendency for the bolt to bounce a bit. This could be good or bad for your application. I just put a timer on the switch input so the PLC had to see a solid on or off for 1 second to react to a change. This eliminated any false positives. Without a controller to monitor the input, the switch will act as a momentary switch if bumped. When tipped to 15-20°, it will get a constant on (dependent on the weight of your bolt).
Step 1: Materials
(1) Pill Bottle (mine is Ø1.25" x 2.75" tall)
(1) Spring from Retractable Pen
(1) 10-24 Bolt, Nut, Washer (yours may vary, just make sure it threads securely into your spring)
(1) 10-24 x Ø.250" x 1.25" Shoulder Bolt (doesn't need to be a shoulder bolt, any bolt with some weight to it will work)
(1) Piece of Copper Shim Stock (enough to fully wrap inside of bottle)
(2) Lengths of 24GA Insulated Copper Wire
(1) Crimp on Loop End Connector
This same switch could be made from any number of alternatives. Get creative with what you have on hand.