SO WHAT EXACTLY IS A TILT SENSOR...WHAT DOES IT DO?
simply put, it is an electronic device, quite small (about the size of an LED); it acts like an ordinary switch, the switch closes when the sensor is tilted and opens when brought to its original position.
and amongst other things, a tilt sensor can be used to determine angular deviation (from the normal).
SO WHAT COMPONENTS DO WE NEED FOR THIS CONNECTION?
- ARDUINO BOARD AND CABLE
- BREADBOARD
- TILT SENSOR
- LED
- 220 OHM RESISTOR (FOR THE LED)
- 10K RESISTOR
- JUMPER WIRE
SEE WHAT THE SKETCH LOOKS LIKE
/*
using tilt sensor to switch an led ON/OFF connected
to pin 3
of the
arduino...
AUTHOR:
ANIEROBI PETER
DATE:
4/23/2014
www.hub360.blogspot.com,
www.facebook.com/hub360circuits
*/
int tilt =4; // tilt sensor connected to digital pin 4
int
led = 3;// led connected to pin 3
int
x;
void
setup(){
pinMode(tilt,INPUT);
//set tilt as input
pinMode(led,OUTPUT); //set led as output
}
void
loop(){
x= digitalRead(tilt); //read to know if tilt is closed
digitalWrite(led,x); //ON or OFF an LED according to detection
}
AND FOR THE CONNECTION
THINK...CREATE...REPEAT
No comments :
Post a Comment