Gravity: Digital 360° Tilt Sensor for Arduino Wiki - DFRobot

Fermion: 全向MEMS麦克风模块

Introduction

This sensor contains a metal ball that moves along its special internal structure on the effect of gravitation force so as to make a connection or disconnection. Therefore, it can be used as a simple tilt switch. With digital input, this sensor can be used with Arduino expansion board to realize various fun interactive works, meanwhile, safer than mercury tilt switch.

Compared with the traditional steel ball tilt switch that can only achieve single-direction tilt detection, this product adopts a cylindrical design to allow inclination detection in 360° directions.

Note:As this product is a switch sensor and cannot measure the tilt angle, it can only guarantee to output switch when tilted from the horizontal plane to the specified angle. If you need to accurately measure the tilt angle, it is recommended to use the triple-axis acceleration sensor.

Specification

Schematic diagram of internal structure:

Schematic diagram of switch angle:

Connection Diagram

Sample Code

int ledPin = 13;                // Connect LED to pin 13
int switcher = 3;                 // Connect Tilt sensor to Pin3

void setup() {
    pinMode(ledPin, OUTPUT);      // Set digital pin 13 to output mode
    pinMode(switcher, INPUT);       // Set digital pin 3 to input mode
}

void loop() {
    if (digitalRead(switcher) == HIGH) //Read sensor value
        digitalWrite(ledPin, HIGH);   // Turn on LED when the sensor is tilted
    else
        digitalWrite(ledPin, LOW);    // Turn off LED when the sensor is not triggered
}

Mind+(Based on Scratch 3.0) Graphical Programming

  1. Download and install software. Download address: http://mindplus.cc/en.html Detailed tutotial:

  2. Switch to "Upload" mode. Detailed tutorial:

  3. In "Extensions", select "Arduino Uno" in "Board". Detailed tutorial:

  4. Program as the picture below.

  5. In menu "Connect Device", select "upload to device"

FAQ

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents