There are many different ways to build tilt switches, both in the factory and in the garage, but I like this idea from Instructables user fjordcarver to use unpainted metal craft beads (e.g. leftmost, above) like liquid mercury in a mercury switch. His tutorial shows how to assemble two such vials to give an SPDT changeover tilt-switch.
- Tilt sensor tutorial on adafruit
- Simple homemade tilt activated switch
- Make a simple tilt-activated switch