Random Nerd Tutorials

Guide for the Tilt Sensor (inclinometer) with Arduino


This post shows how to use the tilt sensor module with the Arduino. The tilt sensor is many times referred to as inclinometer, tilt switch or rolling ball sensor. Using a tilt sensor is a simple way to detect orientation or inclination.

Introducing the Tilt Sensor Module

The tilt sensor module is the one in the following figure.


The tilt sensor allows to detect orientation or inclination. It detects if the sensor is completely upright or if it is tilted.

This makes it very useful to be used, for example, in toys, robots and other appliances whose working methodology depends on inclination.

How does it work?

The tilt sensor is cylindrical and contains a free conductive rolling ball inside with two conductive elements (poles) beneath.


Here’s how it works:

  • When the sensor is completely upright, the ball falls to the bottom of the sensor and connects the poles, allowing the current to flow.
  • When the sensor is tilted, the ball doesn’t touch the poles, the circuit is open, and the current doesn’t flow.

This way, the tilt sensor acts like a switch that is turned on or off depending on its inclination. So, it will give digital information to the Arduino, either an HIGH or a LOW signal.

Where to buy?

You can go to Maker Advisor and find the sensor’s best price.

Pin wiring

Wiring the tilt sensor to you Arduino is pretty straightforward. You just need to connect one pin to an Arduino digital pin and GND to GND.

If you connect the sensor like so, you need to activate the arduino internal pull-up resistor for the digital pin to which your sensor is connected to. Otherwise, you should use a 10kOhm pull up resistor in your circuit.


Example: Tilt sensitive LED

This is just a simple example for you to start put hands on your tilt sensor.


In this example, an LED will be turned off if the sensor is upright, and will be turned on if the sensor is tilted.

Parts required

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!


For this example, you just need to add an LED to the schematics in the “Pin Wiring” section.



To complete this example, upload the following code to your Arduino board.


In the end, this is what you’ll have.


Wrapping up

I hope you’ve found this post useful.

If you would like to know more about Arduino sensors, make sure you check some of the following guides:

Thanks for reading.

Learn ESP32 with Arduino IDE

This is our complete guide to program the ESP32 with Arduino IDE, including projects, tips, and tricks! The registrations are open, so SIGN UP NOW »

Recommended Resources

Home Automation using ESP8266 »
Build IoT projects and home automation gadgets with the ESP8266 Wi-Fi module.

Build a Home Automation System »
Learn how to build a automation system using open-source hardware and software from scratch.

Arduino Step-by-Step Projects »
Build 25 cool Arduino projects with our course even with no prior experience!

Leave a Comment:

Enroll in our Electronics and Programming Courses:

ESP32, ESP8266, Arduino and much more.