Grove - Switch(P)


3.3V 5.0V Digital

This Grove – Switch is a mini SPDT slide, great for “ON/OFF” situations. It is such a reliable switch of great build quality that we adopt it on many of our boards. You should stock some for your Grove prototyping system.

What does “P” mean? “P” is for “panel mount” in this product.


  • Grove Interface
  • Easy to use
  • Basic Grove element


More details about Grove modules please refer to Grove System

Platforms Supported


Below is a simple example showing how to use a switch to turn on/off an LED.The working principle and use just the same as the Grove-Button.

  1. Connect the Grove-LED to the Digital 13 of Grove - Basic Shield and connect the Grove -Switch(P) to the Digital 2 of Grove-Base Shield with two Grove cables.
  2. Plug the Grove - Base Shield into Arduino and connect Arduino to PC by using a USB cable.
  3. Copy and paste code below to a new Arduino sketch.
// constants won't change. They're used here to
// set pin numbers:
const int switchPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int switchState = 0;         // variable for reading the pushbutton status

void setup() {
    // initialize the LED pin as an output:
    //pinMode(ledPin, OUTPUT);
    // initialize the switch pin as an input:
    pinMode(switchPin, INPUT);
void loop(){
    // read the state of the switch value:
    switchState = digitalRead(switchPin);

    if (switchState == HIGH) {
        // turn LED on:
        // digitalWrite(ledPin, HIGH);
        Serial.println("switch high!");
    else {
        // turn LED off:
        // digitalWrite(ledPin, LOW);
        Serial.println("switch low");

After uploading the code, you can see the led will light up when the switch is at high side.


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.


For any technical issue, you are most welcome to contact, our techsupport engineers will help you. Thank you!

Help us make it better

Welcome to the new documentation system of Seeed Studio. We have made a lot of progress comparing to the old wiki system and will continue to improve it to make it more user friendly and helpful. The improvement can't be done without your kindly feedback. If you have any suggestions or findings, you are most welcome to submit the amended version as our contributor via Github or give us suggestions in the survey below, it would be more appreciated if you could leave your email so that we can reply to you. Happy Hacking!