Tilt Switch - NoahMacDonald1/387_NM_Final GitHub Wiki

Tilt Switch

I've included a tilt switch as an additional safety measure. The switch disables all of the box's functions when the box is rattled or tipped beyond a certain point. In addition to the standard function, I've attached an interrupt to the switch, so it can activate at any time in the program, and stop all functions, even when one is in the middle of running. To use interrupts on an Arduino Uno, you need to use either pin 2 or 3. In this case, my tilt switch is connected to pin 2.

A tilt switch and an LED plugged into a breadboard

The tilt switch in this picture is a 4-pin switch. In the real project, I use a SW-520D switch instead. This switch only has two pins, but for my use case, it functions the exact same as a 4-pin.

I also have an LED connected to the switch. It's there as an easy way to tell when the circuit is shut down by the switch. The light will be on until the switch is activated.

Video of the tilt switch in action