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.
Follow these steps to build a sample circuit using this module but without using any microcontroller:
In terms of power modules, use either the Grove - USB Power module or the Grove - DC Jack Power module for the Grove circuit.
Follow these simple steps to build a Grove circuit using the momentary ON/OFF 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. http://www.arduino.cc/en/Tutorial/Button */ // 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); } }
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.
# http://www.seeedstudio.com/wiki/Grove_-_Button import time import grovepi # Connect the Grove Button to digital port D3 # SIG,NC,VCC,GND button = 3 grovepi.pinMode(button,"INPUT") while True: try: print grovepi.digitalRead(button) time.sleep(.5) except IOError: print "Error"
cd GrovePi/Software/Python/
sudo python grove_button.py
The standard Grove - Button module is available as part of the following Grove Kit Series:
Alternatively, it can be bought stand-alone here at the Seeed Studio Bazaar. To buy the Panel Mount version of the module, go here