
Hello guys, welcome back to my SriTu Hobby blog. Today we will learn about Tilt sensors. A tilt sensor can be identified as a device that detects the tilting of a flat plane along different axes. These sensors can easily detect orientation and inclination. Also, these sensors are called Roll ball sensors and Mercury sensors.
Ok, let’s see now how does work these sensors. The cylindrical part of these sensors contains a mercury or metal ball that is designed to move in both directions. Also, there are two conductive elements at one end of this cylindrical section. When the metal ball moves in that direction, the two ends become shorter. The current then flows through these two terminals. For this reason, it acts as a switch. We can also get a signal by connecting this to a circuit.
The main advantages of using these sensors.
- Low cost.
- Low power consumption.
- Simple to use.
- Identify the location of game system controllers.
- For mobile phones and tablets.
- To prevent the capsizing of boats, planes, and vehicles.
- To measure the height of trees and buildings.
- To warn when carrying material that is not suitable for tilt.

- Arduino nano board x 1 — Amazon / Our Store
- Tilt sensor x 1 — Amazon / Our Store
- LED bulb x 1 — Amazon / Our Store
- 180 resistor x 1 — Amazon / Our Store
- Breadboard x 1 — Amazon / Our Store
- Jumper wires — Amazon / Our Store
Step 1






Step 2

Step 3
Now let’s look at the code below.
The complete program of this project – Download
/*Angle[Tilt] sensor with Arduino.
created by the SriTu Tech team.
Read the code below and use it for any of your creations.
*/
#define sensor 2
#define LED 3
void setup() {
Serial.begin(9600);
pinMode(sensor , INPUT);
pinMode(LED , OUTPUT);
}
void loop() {
bool value = digitalRead(sensor);
Serial.println(value);
if (value == 0) {
digitalWrite(LED, HIGH);
} else {
digitalWrite(LED, LOW);
}
}
#define LED 3
Serial.begin(9600);
pinMode(sensor , INPUT);
pinMode(LED , OUTPUT);
}
bool value = digitalRead(sensor);
Serial.println(value);
if (value == 0) {
digitalWrite(LED, HIGH);
} else {
digitalWrite(LED, LOW);
}
Step 4



Step 5

How does work Tilt sensor – Tilt sensor with Arduino nano [Code and circuit diagram]