Grove - Tilt Switch


3.3V 5.0V Digital

The Grove-Tilt Switch 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 Grove.


  • Grove Interface
  • Easy to use
  • Simple Grove module


More details about Grove modules please refer to Grove System


Item Min Typical Max Unit
Voltage 4.75 5.0 5.25 V
Connecting Angle 10° ~170° -
Disconnect angle 190° ~350° -
Electrical Life 100,000 Cycle

Platforms Supported


With Arduino

The SIG pin of the Grove - Tilt Switch output LOW normally. When the Tilt Switch is upright, a pair of balls inside the tilt switch will contact with the pins and the SIG pin will output HIGH.

The following sketch demonstrates a simple application of using the Tilt Switch and Grove - Button to control the led.

  • As the following picture indicates, the Tilt Switch is connected to digital port 5 of the Grove - Base Shield and the Grove-Button to digital port 7. The LED is connected to digital port 2. The hardware installation is as follows:

  • Copy and paste code below to a new Arduino sketch.
void setup()
    pinMode(1, OUTPUT);
    pinMode(5, INPUT);
    pinMode(7, INPUT);

void loop()

    if (digitalRead(5)==HIGH)
        digitalWrite(1, HIGH);
        digitalWrite(1, LOW);

    if (digitalRead(7)==HIGH)
        digitalWrite(1, HIGH);
        digitalWrite(1, LOW);

  • Upload the code.
  • Then the LED will light when you press the button or activate the tilt-switch. Have a try!


The operating angle of Grove-Tilt Switch as shown below:


The mark J1 on the Grove is the reference terminal.

With Raspberry Pi

1.You should have a Raspberry Pi and a Grovepi or Grovepi+.

2.You should have completed configuring the development enviroment, otherwise follow here.


  • Plug Tilt_Switch into grovepi socket D3 by using a grove cable.

4.Navigate to the demos’ directory:

       cd yourpath/GrovePi/Software/Python/
  • To see the code
    nano   # "Ctrl+x" to exit #
    import time
    import grovepi

    # Connect the Grove Tilt Switch to digital port D3
    tilt_switch = 3


    while True:
            print grovepi.digitalRead(tilt_switch)

        except IOError:
            print "Error"

5.Run the demo.

    sudo python

6.Result: Put the sensor upright by one side, the SIG pin will output HIGH.


ArduinoWioBeagleBoneRaspberry PiLinkIt ONE


The platforms mentioned above as supported is/are an indication of the module's hardware or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.

Help us make it better

Thank you for choosing Seeed. A couple of months ago we initiated a project to improve our documentation system. What you are looking at now is the first edition of the new documentation system. Comparing to the old one, here is the progresses that we made:

  • Replaced the old documentation system with a new one that was developed from Mkdocs, a more widely used and cooler tool to develop documentation system.
  • Integrated the documentation system with our official website, now you can go to Bazaar and other section like Forum and Community more conveniently.
  • Reviewed and rewrote documents for hundreds of products for the system’s first edition, and will continue migrate documents from old wiki to the new one.

An easy-to-use instruction is as important as the product itself. We are expecting this new system will improve your experience when using Seeed’s products. However since this is the first edition, there are still many things need to improve, if you have any suggestions or findings, you are most welcome to submit the amended version as our contributor or give us suggestions in the survey below, Please don’t forget to leave your email address so that we can reply.

Happy hacking