Tilt Sensor

Interaction
Techniques & Concepts

Introduction

A tilt sensor is a gadget that can figure out the angle or inclination of the object it's attached to, helping to understand whether something is level or if it’s tilted to one side. Similar to a button, it has an “on” or “off” state that helps us know if the sensor is tilted to one side or the other.

Circuit Assembly

Connect the tilt sensor to any digital pin. In our example, we're using D11/D10. The pin that you connect your tilt sensor to corresponds to a pin value on your code. We're using D11/D10, which corresponds to 11. You can remix yours to look like this:
• D11/D10 → tilt_pin = 11;
• D9/D8 → tilt_pin = 9;
• D7/D6 → tilt_pin = 7;
• D5/D4 → tilt_pin = 5;
• D3/D2 → tilt_pin = 3;
• D1/D0 → tilt_pin = 1;

Code