Tilt Sensor with Arduino

Description
  
        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. In this project, the basic functioning of a tilt sensor in determining the orientation is demonstrated. Okey, let's see how it works.  

Components Required

 1. Arduino UNO     * 1
 2. Tilt Sensor  * 1
 3.  LED  * 1
 4. Buzzer  * 1
 5. Resistor(220 ohm)   * 1
 6. Bread Board  * 1
 7. Jumper Wires  * 1

 Circuit Diagram










Program

void setup() {
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, INPUT);

}

void loop() {
  if (digitalRead(4) == 1)
  {
  digitalWrite(2, HIGH);   
  digitalWrite(3, HIGH);
  delay(300);                       
  digitalWrite(2, LOW);    
  digitalWrite(3, LOW); 
  delay(300);  
  }

}