Sunday, October 11, 2015

ARTICLE #7 Tilt sensor

What is a tilt sensor ?



Next time when you play Tomb Raider on your PS3, you are controlling the movements of Lara Croft with the analogue joystick, remember that you are using a bunch of tilt sensors.These sensors allow the movement of your thumb on the joystick be transformed into the movements you see on the screen when you are playing.



The tilt sensor, usually called tilt switch, is a small low-power 2-pin electrical device that simply indicates if a system is inclined or not in reference to earth’s surface. It is its simplicity that made it popular for many applications in robotics, Aircraft Flight Controls, automotive systems …etc.



In this article, we will explore in depth the functioning of the tilt sensor by making a simple project. But first, here are some features of this device.




Some features of the tilt sensor :


How does a tilt sensor work :


Circuit wiring :


     Project parts :



To realize this project you will need :

  • 1 Arduino Uno.
  • 1 Breadboard.
  • 1 Tilt sensor.
  • 1 LED.
  • 2 Resistors.
  • Connector wires.


     Wiring :


In this project, the tilt sensor can sense the orientation of the circuit. It turns the LED on when the circuit is turned upside down.

Connect the parts of the circuit as seen in the picture below. 

Notice that I connected the tilt sensor pin to a pull-up resistor. So the pin takes the logic value “1” when the switch is open and value “0” when the switch is closed.





Code :


int led = 10;
int tilt = 4;

void setup() {

  pinMode(led, OUTPUT);
  pinMode(tilt, INPUT);

}

void loop() {

  int tiltVal = digitalRead(tilt);

  if(tiltVal == 1)
  digitalWrite(led, HIGH);  
  else            
  digitalWrite(led, LOW);    

}



No comments:

Post a Comment