LM393 TILT SENSOR

tilt-sensor-module

Description

The tilt sensor is a component that can detect the tilting of an object. However it is only the equivalent to a pushbutton activated through a different physical mechanism. This type of sensor is the environmental-friendly version of a mercury-switch. It contains a metallic ball inside that will commute the two pins of the device from on to off and vice versa if the sensor reaches a certain angle.

Specifications

  1. On-board LM393 voltage comparator chip and photo activity sensing probe.
  2. Support 5V/3.3V voltage input.
  3. On-board signal output instructions, output the effective signal is low-lever at the same time indicator light off.
  4. Output signal can directly connect with the microcontroller IO.
  5. The sensitivity of the signal detection can be adjusted.
  6. Reserve a line voltage to compare circuit (P3 has been leaded out)
  7. PCB size: 30(mm) x15(mm)

Applications

The following are key applications of tilt sensors:
1.To monitor the angle at which a mobile phone or tablet is held for the auto-rotate function
2.To detect the position of hand-held game systems and in game controllers
3.To indicate roll of boats, vehicles and aircraft
4.To measure the angle at which a satellite antenna 'looks' toward a satellite.
5.To estimate the height of a tree or building using
6.To measure the steepness of a ski slope
7.As a warning system for the tilt angle of the surface cryogenic liquids during transportation
8.To monitor laser levels and seismic activity

Pin Configuration

tilt-sensor-module-pinout-1-1

Schematic Diagram

schematic-diagram-of-tilt-sensor

Wiring Diagram with Arduino

tilt-sensor-

Wiring Diagram with Raspberry pi

wiring-diagram-with-raspberry-pi

Arduino Code

void setup() {
pinMode(2, INPUT); 
pinMode(13, OUTPUT); 
Serial.begin(9600); 
} 
void loop(){ 
if(digitalRead(2) == HIGH){ 
digitalWrite(13, HIGH); 
Serial.println("tilted!");
} 
else{ 
      digitalWrite(13, LOW); 
      Serial.println("not tilted");
     } 
      delay(250); 
}

Python Code



import pygame.mixer

from time import sleep

import RPi.GPIO as GPIO

from sys import exit



GPIO.setmode(GPIO.BCM)

GPIO.setup(24, GPIO.IN)


print "Ready."


while True:


 try:


   if GPIO.input(24):


     print "HIGH"


   else:

      print "LO"

 sleep(1)

except KeyboardInterrupt:

exit()