How To Make A Tilt Sensor With Arduino
How To Make A Tilt Sensor With Arduino
YOU ARE HERE: HOME / ARDUINO / HOW TO MAKE A TILT SENSOR WITH ARDUINO?
A Tilt Sensor or a Tilt Switch is a component that detects orientation of an object. One of
the best example for the application of a tilt sensor is its use in aircrafts.
The horizontal and vertical orientation or inclination of the airplane will be provided by the
tilt sensor to on board computers. This information is provided to the pilot for safe
travelling.
There are different types of tilt sensors based on the axes it can measure.
A simple tilt sensor is basically a switch that will turn ON or OFF based angle or
orientation of the sensor. Such sensor is useful for single axis tilt detection.
In this project, the basic functioning of a tilt sensor in determining the orientation is
demonstrated.
Select the Next Set of Arduino Projects You Want to Learn in Electronicshub: Arduino
Projects»
Outline
Circuit Diagram
Components Required
Circuit Design of Arduino Tilt Sensor
Working of Arduino Tilt Sensor
Code
Circuit Diagram
Components Required
Arduino UNO [Buy Here]
Tilt Sensor
LED
Resistor
Buzzer
A buzzer and an LED are used to indicate the detection of the tilt by Arduino. The buzzer
is controlled by the PWM output of the Arduino to generate different tones.
Hence, positive terminal of the buzzer is connected to any of the PWM pins of the
Arduino. In this demonstration, it is connected to pin 6. The other terminal of the buzzer
is connected to ground.
LED is also used to indicate the tilt action. As the output current from Arduino is only
20mA, we are connecting the LED directly to Arduino without any current limiting resistor.
It is advised to use a current limiting resistor just to be safe. Anode of the LED is
connected to pin 13 of the Arduino while the cathode is connected to ground.
There are different types of tilt sensors. For a simple one axes orientation, a tilt switch
with accurate angle of orientation can be used. An accelerometer based 3- axis tilt
sensor is used to detect full motion in three axes.
In this project, we used a single axes tilt sensor. There are two technologies that are used
in the implementation of Tilt Sensors: Mercury based and Roller Ball based. Older tilt
sensors are made of mercury.
A blob of mercury is placed in a small glass tube with two metal contacts coming out.
When the sensor is held upright, the mercury will make contact with both the terminals
and the switch is closed.
When the sensor is tilted in either direction, the mercury goes off contact with the
terminals and the switch is open.
In roller ball based tilt sensors, one or two metal balls are used to close or open the
switch. When the sensor is positioned upright, the metal ball makes contact with both
the terminals and closes the switch.
When the orientation of the sensor is changed i.e. tilted at an angle, the metal ball loses
contact with the terminals and the switch is open.
The advantage of mercury based tilt sensor is that there is no chance of de-bouncing.
But due to the toxic nature of mercury, the usage of such type of tilt sensors is reduced.
Irrespective of the type of the sensor used, the best way to test the tilt sensor is by using
the following circuit. It consists of a tilt sensor, an LED, a current limiting resistor and a
power source like battery.
When the sensor is held upright, the circuit is closed. Current flows through the LED and
it glows. When the orientation of the sensor is changed, the circuit is open and the LED is
turned off.
Another simple way to test the tilt sensor is using a multimeter. The multimeter is set to
continuity mode and the terminals of multimeter are connected to tilt sensor. The angle
at which the switch opens and closes can be determined by this test.
In this project, an Arduino will sense the tilt of the sensor and triggers a buzzer and an
LED. The code for Arduino is written and uploaded to the board.
When the tilt of the sensor is detected, the buzzer and LED are triggered by Arduino.
Code
1 #define SENSOR_PIN 2
2 #define LED_PIN 13
3
4 void setup()
5 {
6
7 pinMode(SENSOR_PIN, INPUT_PULLUP);
8
9
10 pinMode(LED_PIN, OUTPUT);
11 }
12
13 void loop()
14 {
15
16 if (digitalRead(SENSOR_PIN) == LOW)
17 {
18
19 digitalWrite(LED_PIN, HIGH);
20 }
21 else
22 {
23
24 digitalWrite(LED_PIN, LOW);
25 }
26 }
NOTE
Related Posts:
List of Arduino Compatible Modules | Arduino Modules…
Interfacing Flex Sensor with Arduino - Hookup Guide…
Interfacing Knock Sensor with Arduino (Vibration/Tap Sensor)
How to Interface LM393 Speed Sensor with Arduino?