Grove - Button

From Wiki
Jump to: navigation, search


The Grove - Button is a momentary push button. It contains one independent "momentary on/off" button. “Momentary” means that the button rebounds on its own after it is released. The button outputs a HIGH signal when pressed, and LOW when released. The button signals the SIG Pin of the Grove Interface while NC is not used at all. There are two versions of this button available as shown in the pictures. The only difference between them is the direction of the Grove socket.

300px-Button.jpg300px-Grove - ButtonP.jpg


Easy to use momentary ON/OFF button Uses Standard 4-pin Grove Cables to connect to other Grove modules such as Grove Power Modules and Grove - Base Shield Usage

Standalone Follow these steps to build a sample circuit using this module but without using any microcontroller: Connect the button module to the input side of your circuit (to the left of the power module). On the output side of the circuit, you may use a range of User Interface modules (Grove - Red LED, Grove - LED String Light, Grove - Mini Fan, Grove - Buzzer, Grove - Recorder etc.) Power up the circuit when complete. The button module can now be used to trigger an output. For example: When used in conjunction with a Grove - Red LED output module, observe that the LED turns ON when you press the button and turns OFF when you stop pressing it.


In terms of power modules, use either the Grove - USB Power module or the Grove - DC Jack Power module for the Grove circuit. With Arduino Follow these simple steps to build a Grove circuit using the momentary ON/OFF button: When using the module in conjunction with an Arduino or a Seeeduino, use the Grove - Base Shield and connect the Grove - Button module to the shield using a designated Grove Interface. Also attach an output module such as a Grove - Red LED which will get triggered based on input received from the button. Upload the following sample sketch to make the LED turn ON and OFF based on input from Grove - Button: //Turns on and off a light emitting diode(LED) connected to digital pin 13, when pressing a pushbutton attached to pin 2.


The circuit:
* LED attached from pin 13 to ground 
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground

* Note: on most Arduinos there is already an LED on the board
attached to pin 13.

This example code is in the public domain.

// constants won't change. They're used here to // set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin const int ledPin = 13; // the number of the LED pin

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

void setup() {

 // initialize the LED pin as an output:
 pinMode(ledPin, OUTPUT);      
 // initialize the pushbutton pin as an input:
 pinMode(buttonPin, INPUT);     


void loop(){

 // read the state of the pushbutton value:
 buttonState = digitalRead(buttonPin);
 // check if the pushbutton is pressed.
 // if it is, the buttonState is HIGH:
 if (buttonState == HIGH) {     
   // turn LED on:    
   digitalWrite(ledPin, HIGH);  
 else {
   // turn LED off:
   digitalWrite(ledPin, LOW); 

} With Raspberry Pi This is a simple example of Raspberry Pi.Run Program and press button,it will print 1 on the terminal ,else print 0. Such as the picture below.

400px-GrovePi+ grove button.jpg 400px-Grovepi+ grove button terminal.jpg


import time import grovepi

  1. Connect the Grove Button to digital port D3

button = 3


while True:

       print grovepi.digitalRead(button)
   except IOError:
       print "Error"

Run The Program Find the path to the file(According to your own path)

 cd GrovePi/Software/Python/

Run Progrom

 sudo python


The standard Grove - Button module is available as part of the following Grove Kit Series: Grove Mixer Pack V2 Grove - Mixer Pack GROVE - Starter Kit V1.1b Alternatively, it can be bought stand-alone here at the Seeed Studio Bazaar. To buy the Panel Mount version of the module, go here Resources