Part

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

or see every part
  • 4 pins
  • 1 property
Drawn live by the editor's own code, at the size you see it.
Reference

Every one of its 4 pins

Pin
What it does
1a
One pair, always shorted together.
1b
One pair, always shorted together.
2a
The other pair, always shorted together.
2b
The other pair, always shorted together.
This part

What it does

The real part has two pairs of legs, and each pair is always one piece of metal: pins 1a and 1b are permanently joined, and so are 2a and 2b, whether the button is held or not. Pressing it is what bridges the two pairs together. That matters on a breadboard because wiring across the gap the wrong way is a genuine, common mistake, and the model carries the straps rather than pretending the part is a simple two-pin switch. It also bounces. A real tactile switch’s dome does not land once; it chatters for a few milliseconds before it settles, on both the press and the release, and this part reproduces that by default rather than closing its contact cleanly. That single detail is the whole reason a naive sketch counts one press as two or three, and it is the reason every debouncing tutorial on this site can show the problem happening rather than only describing it.

How to use it

How to use a pushbutton with an Arduino

The simplest wiring needs no resistor: one side of the button to a digital pin, the other to GND, and pinMode(pin, INPUT_PULLUP) in setup(). The pin then reads HIGH when the button is up and LOW while it is pressed, which is backwards from what most people expect the first time.

A real button bounces for a few milliseconds when it closes, and so does this one, so a sketch that counts presses needs a debounce: ignore changes for 20 milliseconds or so after each one. The circuit here is that fix, running.

Part pin
Board pin
One side (1a)
Pin 2
The other side (2a)
GND

The same wiring works on every board here; the ESP32-C3 button example uses GPIO 9 and the Pico’s uses GP15.

Arduino Uno: a debounced togglelive0.000 s 0.00x
Hold the button
This is the simulator itself, running here. Click anything to open it in the editor.
Read the full tutorial
Reading a button with the internal pull-up
void setup() {
  pinMode(2, INPUT_PULLUP);
  pinMode(13, OUTPUT);
}

void loop() {
  bool pressed = digitalRead(2) == LOW;
  digitalWrite(13, pressed ? HIGH : LOW);
}
Reference

The one property you can set

Property
Default
What it means
bounce
typical (or none, worst)
none, typical (1 to 5 ms, the small tactile switch most kits ship, the default) or worst (10 to 20 ms, a tired microswitch or a long-levered limit switch).
How it is modeled

What is true about the Pushbutton, here

What is modeled

A tactile switch is a springy dome slapping a fixed contact: it does not close once, it closes, rebounds, closes again, and settles after a few milliseconds of chatter, on the release as well as the press, because the dome rebounds both ways. That is why a button wired straight to a counter counts several presses for one, and why every real sketch that reads a button debounces it; a simulator that closes the contact exactly once would hide the single most common reason a beginner's circuit misbehaves. The numbers come from a per-part random stream seeded from the component id, so every button bounces differently, every press bounces differently from the last, and the same circuit run twice bounces identically.

Not modeled

No mechanical click force or travel feel. This is the electrical bounce, not the tactile feedback.

The bounce is a plausible pattern, not a measured waveform. When the button is pressed, the model generates a plan: an odd number of edges (3 to 8 on typical, 11 to 20 on worst) with random gaps scaled so the last one lands exactly on a settle time drawn from the profile's window: 1 to 5 ms, or 10 to 20 ms. The numbers are representative of a small tactile switch rather than taken from any one switch's datasheet, the gaps are drawn from a seeded pseudo-random stream rather than from contact mechanics, and the first edge is always clean and immediate. A real dome's chatter is decaying rather than uniformly spread, and its contact resistance wanders during the bounce; here it is fully closed or fully open at every instant.

There is no contact resistance drift, no wetting current, no wear and no temperature.

From Pushbutton (12 mm tactile), in full.

Projects

See the Pushbutton in a project

Shown here on: ESP32-C3-DevKitM-1, Arduino Uno R3, BBC micro:bit V2

Wire up the Pushbutton

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.