click here to enter

Push Button - Kingston hackSpace

Kingston hackSpace

Push Button

There are many different types of buttons and they allow you to control a DC power source, by simply cutting the voltage. Push-button is the simplest type of button; the breakout uses a latching analog circuit that is triggered by a push of the button. Press once to turn on, and then press again to turn off. There are already pre-made modules that can be used with a microcontroller, however in the example below we will you normal push-button to and wire it up using breadboard.

The button works fine with 3V and it can go up to 14V, in this case we will use 5V from the Arduino. We also need to wire a ground, which will complete the circuit; it is safer to connect a 10K pull-down resistor between the GND and button. Also in this example we will add a signal form a button to Arduino that will be connected to any of the digital pins. In this case we can measure the on/off signal on the computer.


button to serial output

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

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

void setup() {
  // 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:
  } else {
    // turn LED off: