Difference between revisions of "Tilt Module"

From LinkSprite Playgound
Jump to: navigation, search
Line 1: Line 1:
 +
==Introduction==
 +
The Linker Tilt Module is the equivalent of a button, and is used as a digital input. Inside the tilt switch is a pair of balls that make contact with the pins when the case is upright. Tilt the case over and the balls don't touch, thus not making a connection. It is wired to the SIG line, NC is not used on this kit.
 +
 
[[File:Linker tilt2.jpg |400px]]
 
[[File:Linker tilt2.jpg |400px]]
  
Line 5: Line 8:
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
  
const int ButtonPin=9;
+
int ledPin = 13;
void setup() {
+
int switchPin = 7;
   pinMode(ButtonPin, INPUT);
+
int val = 0;
   Serial.begin(9600);       // init serial to 9600b/s
+
void setup()
 +
{
 +
   pinMode(ledPin,OUTPUT);
 +
   pinMode(switchPin,INPUT);
 +
}
 +
void loop()
 +
{
 +
  //digitlRead(switchPin,HIGH)
 +
  val = digitalRead(switchPin);
 +
  if (HIGH == val)  digitalWrite(ledPin,HIGH);
 +
  else  digitalWrite(ledPin,LOW);
 
}
 
}
 
void loop() {
 
  int sensorValue = digitalRead(ButtonPin);
 
  if(sensorValue==1)
 
  {
 
    Serial.println("Hign");   
 
  }
 
  else
 
  {
 
    Serial.println("Low");   
 
   
 
  }
 
}
 
  
  

Revision as of 06:41, 8 April 2014

Introduction

The Linker Tilt Module is the equivalent of a button, and is used as a digital input. Inside the tilt switch is a pair of balls that make contact with the pins when the case is upright. Tilt the case over and the balls don't touch, thus not making a connection. It is wired to the SIG line, NC is not used on this kit.

Linker tilt2.jpg

Sample

<syntaxhighlight lang="c">

int ledPin = 13; int switchPin = 7; int val = 0; void setup() {

 pinMode(ledPin,OUTPUT);
 pinMode(switchPin,INPUT);

} void loop() {

 //digitlRead(switchPin,HIGH)
 val = digitalRead(switchPin);
 if (HIGH == val)  digitalWrite(ledPin,HIGH);
 else  digitalWrite(ledPin,LOW);

}


</syntaxhighlight>

Schematics

How to buy

Here to buy Tilt Module on store