Loading...

Learning   Examples | Foundations | Hacking | Links

Tilt Sensor

The tilt sensor is a component that can detect the tilting of an object. However it is only the equivalent to a pushbutton activated through a different physical mechanism. This type of sensor is the environmental-friendly version of a mercury-switch. It contains a metallic ball inside that will commute the two pins of the device from on to off and viceversa if the sensor reaches a certain angle.

The code example is exactly as the one we would use for a pushbutton but substituting this one with the tilt sensor. We use a pull-up resistor (thus use active-low to activate the pins) and connect the sensor to a digital input pin that we will read when needed.

The prototyping board has been populated with a 1K resitor to make the pull-up and the sensor itself. We have chosen the tilt sensor from Assemtech, which datasheet can be found here. The hardware was mounted and photographed by Anders Gran, the software comes from the basic Arduino examples.

Circuit

Picture of a protoboard supporting the tilt sensor, by Anders Gran

Code

Use the Digital > Button example to read the tilt-sensor, but you'll need to make sure that the inputPin variable in the code matches the digital pin you're using on the Arduino board.