Tactile Button Switch
Category:
Subcategory:
Signal Type:
Binary (on/off)
IDeATe Component Number:
0356
Makes an electrical connection when pressed.
Tactile Button Switch
About

Push-button switches are the classic momentary switch, as they only remain in their "on" state as long as they’re being actuated (pressed, held, etc). (adapted from Sparkfun)

When pressed, the tactile button switches connect two points in a circuit by allowing electricity to flow through. Tactile Button Switches have four pins, which can be a little confusing, but because pins B and C are connected together as well as A and D, there are only really two electrical connections. (adapted from Adafruit)

Tactile Button Switch Interior
The interior wiring of a Tactile Button Switch | Image from Adafruit

When wiring a breadboard, the convention is for the positive and negative power lines to lie on opposite sides of the board. Therefore, the standard set-up is to place the push-button running across the middle of the breadboard, and connect the electrical leads to A and C, or B and D.

Button wired across the valley of the breadboard
Button wired across the valley of the breadboard
Getting started

The below code and schematic sets up a circuit where pressing the button turns the LED on, and leaving the button off turns the LED off.

schematic for code below
schematic for code below
const int LEDPIN = 5;
const int BUTTONPIN = 11;

void setup() 
{
  pinMode(BUTTONPIN, INPUT);
  pinMode(LEDPIN, OUTPUT);
}

void loop() 
{
  if (digitalRead(BUTTONPIN) == LOW)
  {
    digitalWrite(LEDPIN, LOW);
  }
  else
  {
    digitalWrite(LEDPIN, HIGH);
  }
}
Resources
Related Components