Tilt Switch Arduino Schematics

1,333 views

Tilt switches are commonly used to detect motion or orientation. They are used to detect slope or inclination relative to gravity and are set to trigger outputs at limits outside a safe operating zone. It is a small inexpensive easy-to-use sensor, by connecting this tilt sensor with Arduino we can control LED, buzzer, or other output devices. Tilt switches transfer a change of state to another device. These devices receive a signal from the tilt sensor for changes in motion or orientation and turn on or off. They do this by generating an artificial horizon and measuring angular tilt with respect to this horizon. Not all products open or close a switch. Some, such as tilt switch alarms, trigger audible or visual responses to notify an operator that a system is out of alignment. Tilt switches are made of nonconductive tubes that have two electrical contacts and a material that acts as a conductor between the two electrical contacts.

Hardware Required

S.NoComponentsValueQty
1Arduino Uno1
2Tilt Switch Sensor1
3Resistor 220Ω,100KΩ1,1
4Connecting Wires
5LED1

Circuit Diagram

Working Explanation

Here we interfaced the tilt sensor with the Arduino board and LED as an output indicator, and connect a 10KΩ bias resistor between the ground (GND) and one terminal of the tilt sensor that is connected to the Arduino digital input pin. Now as in this sensor, two conducting poles are placed and the mass roller is placed between these two pole elements. When the orientation of the sensor changes downwards the mass role shorts the two poles and acts as a switch throw.

Arduino Sketch

int SensorPin = 2;
int LEDPin = 13;

int LEDstate = HIGH;
int reading;
int previous = LOW;

long time = 0;
long debounce = 50;

void setup()
{
pinMode(SensorPin, INPUT);
digitalWrite(SensorPin, HIGH);
pinMode(LEDPin, OUTPUT);
}

void loop()
{
int switchstate;

reading = digitalRead(SensorPin);
if (reading != previous) {

time = millis();
}

if ((millis() – time) > debounce) {

switchstate = reading;

if (switchstate == HIGH)
LEDstate = LOW;
else
LEDstate = HIGH;
}
digitalWrite(LEDPin, LEDstate);

previous = reading;
}

Applications

Tilt switches are used in many different applications. These include:

  • Construction Equipment
  • Cameras
  • Automobile airbags
  • Aircraft flight controls
  • Automobile security systems
  • Video cameras
  • Robots
  • Video game controllers
  • Thermostats
  • Studying human movement