Source: https://mokxi.com/parts/pushbutton
Updated: 2026-09-27

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.

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

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

Learn

## Where it turns up in a lesson

### In the twelve week course

- Week 3: Buttons, pull-ups and contact bounce
- Week 5: Logic gates, as real chips
- Week 11: Interrupts: events instead of polling

### In a learn article

- How to Use a Breadboard: Your First Circuit
- Picking a Resistor for an LED
- Pull-Up Resistors and the Floating Input They Fix
- Debouncing a Button: Why It Fires More Than Once
- Logic Gates, and the Truth Table You Can Press
- Shifting a Byte In, One Edge at a Time
- Arduino Button Debounce: See the Bounce, Then Fix It
- How to Simulate an Arduino Project Without Hardware
- Arduino Traffic Light with a Crossing Button
- Arduino 7 Segment Display: an Electronic Die
- Arduino Buzzer and Piezo: Beeps, Notes, Metronome
- Voltage Dividers and Why They Are Bad Power Supplies
- The 555 Monostable: One Press, One Timed Pulse
- Arduino State Machine: A Four-State Reaction Game
- Flip-Flops Explained: SR Latch, D and JK Flip-Flops
- Arduino Science Fair Projects With a Real Hypothesis
- Reaction Time Science Fair Project With an Arduino
- 555 Timer Projects for a Science Fair (No Coding)
- Arduino Projects for Beginners, Each One Running

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio, no real internet), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

STM32F411 Black Pill

The Black Pill on our own Cortex-M4 core. Pick a program and press Run.

BBC micro:bit V2

The nRF52833 board with its 5x5 LED matrix, buttons A and B and a speaker. Wire the rings to a breadboard.

STM32 Blue Pill (F103)

The Blue Pill on our own Cortex-M3 core, with an ADC. Pick a program and press Run.

See every part

## Wire up the Pushbutton

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

Start building Open the editor
