Grove Momentary Push Button

Grove Momentary Push ButtonGrove_-_ButtonP

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.

Wiring

PushButtonWithLED_bb

Sketch
const int buttonPin = 2;    

// SIG pin in the push button
const int ledPin =  13;      

// Autonomo built-in LED  
// variable for reading the pushbutton status 
int buttonState = 0;         

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);  
 }
}