Ball Tilt Switch Module

Ball Tilt Switch Module

Description

This ball tilt switch module can detect when it is tilted. It works because a ball flows into the gap between two electrodes and completes the circuit when the module is tilted at an angle.

Test Code

int Led = 13; // define LED Interface
int buttonpin = 3; // define the tilt switch sensor interfaces
int val; // define numeric variables val

void setup () {
pinMode(Led, OUTPUT); // define LED as output interface
pinMode(buttonpin, INPUT); // define the output interface tilt switch sensor
}

void loop () {
val = digitalRead(buttonpin); // digital interface will be assigned a value of 3 to read val

// When the tilt sensor detects a signal when the switch, LED flashes
if (val == HIGH) {
digitalWrite(Led, HIGH);
}
else {
digitalWrite(Led, LOW);
}
}

Write a review

Please login or register to review
  • Views: 2528
  • Brand: Tiah
  • Product Code: DZD002409
  • Availability: 9
  • 250.00DA
  • Ex Tax: 250.00DA

Tags: ball, tilt, switch, module