Tilt Sensor with Arduino

In this tutorial, we will learn how to interface a tilt sensor with Arduino.

A tilt sensor is used to detect a movement, tilted or shaken of an object.

The tilt sensor is commonly a ball bearing in a box with contacts at one end. When the box is tilted the ball rolls away from the contact and the connection is a loss.

On the other hand, when the box is tilted to roll the other way the ball touches the contact and completes the circuit.

The tilt sensor is sensitive to small movement of around 5 to 10 degrees when oriented with the ball just touching the contacts.

Must See:

tilt sensor

Tilt Sensor Pinout

Tilt Sensor has three pins are:

  • GND
  • 5V / VCC
tilt sensor pinout

Components Needed

  • Arduino.
  • Tilt Sensor.
  • LEDs.
  • Breadboard.
  • Jumper Wires.

Circuit Diagram for Tilt Sensor with Arduino

Circuit Diagram for Tilt Sensor with Arduino


The code uses a switch that closes a circuit when tilted, called a tilt sensor.

The below code will switch on the LED attached to pin 11 when the tilt sensors are tilted one way, and the LED connected to pin 12 will switch on when it is tilted the other way:

Use of only Tilt Sensor Switch with Arduino

The tilt sensor switch is the main part of the whole sensor module. We can only use this switch with Arduino.

The following figure is of the tilt sensor switch.

tilt sensor switch

Circuit Diagram for Tilt Switch

Circuit Diagram for Tilt Switch

Code for Tilt Switch


output tilt sensor wih arduino

Detect Change in the State of Sensor

To determine if something is being shaken, we need to check how long it’s been since the state of the tilt sensor changed.

If it hasn’t changed for a time you consider significant, the object is not shaking. Changing the orientation of the tilt sensor will change how vigorous the shaking need to be to trigger it.

Remove the LED from Pin 11.

Code for Check the Sensor state

The following code turns on an LED when the sensor is shaken.

Some More Articles For You:

Scroll to Top