TK05DIGITALbeginner

Latching Button

A push-on, push-off switch with its pull-down and a red indicator LED already fitted: one press turns SIGNAL HIGH and it stays HIGH, through a reset or a power cut, until the next press.

Comes in this kit — not sold separately

Specifications

TypeLatching switch input block, active high: press on, press again off
Switch12 × 12 mm self-locking push switch, ON–OFF single pole, 5.4 mm button. Its top stands 9 mm above the board
Switch ratingDC 30 V 1 A, contact resistance 200 mΩ or less, at least 50,000 cycles, from the switch's drawing
Operating force700 ± 100 gf, from the switch's drawing: a firm press
Pull-down10 kΩ from SIGNAL to GND, fitted. Off reads LOW, on reads HIGH
IndicatorRed LED on SIGNAL through 1 kΩ: lit whenever the switch is on and VCC is connected
Signal levelSIGNAL equals VCC when on, so VCC sets it: 3V3 beside a 3.3 V board, 5V on an Uno
CurrentNone with the switch off. About 3.5 mA from 5 V and 1.6 mA from 3.3 V when on, worked out from the parts
Pins to wire3 of the 4: GND, VCC and SIGNAL. NC is connected to nothing on the board
Header4-pin right-angle male, 2.54 mm pitch: GND, VCC, NC, SIGNAL, with GND on the square pad
Board22.4 × 30.4 mm, two 4.8 mm mounting holes 16 mm apart
In the box1 × TK05 block. It also ships inside the TinkerBlock kits

What it is

A push switch that stays where you leave it. Press it once and it latches on; press it again and it goes off. SIGNAL is HIGH while it is on and LOW while it is off, so your sketch reads a level, a position, rather than catching a press.

Because the state is held by a mechanical latch, it survives anything short of a press: a reset, a crash, the USB cable coming out. A sketch that reads it in setup() starts in the state it was left in. The trade is that software can read it and never change it, so it suits choices a person makes and leaves made, such as a mode.

The TK05 at an angle: a black board with a gold-plated border, a large square black push switch with a round button standing up from the top half, two small resistors at the right-hand edge, a tiny LED below the switch, two big mounting holes, lonely binary and LATCHING SWITCH printed along the left edge, a boxed ACTIVE HIGH on the right, and a right-angle header whose four pins point out past the bottom edge.
The TK05. The header is right-angled, so the board lies flat.

What is on the board

Three parts besides the switch, all on one wire. A 10 kΩ pull-down from SIGNAL to GND holds it at 0 V while the switch is open. The switch joins SIGNAL to VCC when it is on. A red LED with a 1 kΩ resistor hangs off SIGNAL, so it lights exactly when the switch is on. It shows the switch's position, not your sketch's.

VCC goes to the switch and to nothing else, so with the switch on, SIGNAL is VCC. That makes VCC the one pin to wire by your board: 3V3 beside an ESP32, an ESP32-S3 or a Pico, 5V on an Uno.

Which pin is which

Switch side up, header at the bottom, reading left to right:

GNDto your board's GNDthe square pad: count from here
VCCto 3V3, or 5V on an UnoSIGNAL's voltage when on
NCnothingnot connected on the board
SIGNALto a digital inputHIGH when the switch is on

The back prints TK05 LATCHING BUTTON and PRESS TO TURN ON, PRESS AGAIN TO TURN OFF instead of pin names. Turned over, the square pad is on the right, and it is still GND.

Wiring, in three lines

  1. GND to your board's GND.
  2. VCC to 3V3 on an ESP32, ESP32-S3 or Pico; to 5V on an Uno.
  3. SIGNAL to a digital input: D2 on an Uno, GPIO 25 on an ESP32, GPIO 4 on an ESP32-S3, GP15 on a Pico.

Leave NC unconnected. Set the pin as a plain input; the pull-down is on the board.

Example

// The GPIO number SIGNAL is wired to.
// Uno: 2. ESP32: 25. ESP32-S3: 4. Pico: 15.
const int SWITCH_PIN = 4;

void setup() {
  Serial.begin(115200);
  pinMode(SWITCH_PIN, INPUT);   // the board's pull-down holds it LOW
}

void loop() {
  if (digitalRead(SWITCH_PIN) == HIGH) {
    Serial.println("ON");       // latched: SIGNAL is VCC
  } else {
    Serial.println("OFF");
  }
  delay(500);
}
The Latching Button on an Arduino Uno

Where to start

The handbook below is nine short articles, each with a working figure. The first read is the whole build in three wires and a dozen lines.

If you only read one, read which supply to use. VCC is the one wire on this block that has to match your board, and getting it wrong looks like it works.

And for what makes this block different from a push button, surviving a reset turns the latch into a mode switch that a reset cannot move.

When it doesn’t work

It reads LOW whatever I do.
Look at the red LED. If it never lights, VCC is not wired: the switch connects SIGNAL to VCC, and with no VCC it connects it to nothing, so the pull-down keeps it LOW. If the LED lights and the sketch still reads LOW, SIGNAL is on a different pin from the one the sketch reads.
Should I use INPUT_PULLUP?
No, use INPUT. The block has a 10 kΩ pull-down fitted, so SIGNAL is held at 0 V with the switch off and pulled to VCC with it on. An internal pull-up only fights the pull-down. In MicroPython, Pin.IN with no pull argument.
Can I power it from 5V on an ESP32 or a Pico?
No. When the switch is on, SIGNAL is VCC, so a 5 V supply puts 5 V on a pin rated for 3.3 V. It will appear to work, which is the problem. Wire VCC to 3V3 on an ESP32, ESP32-S3 or Pico, and to 5V on an Uno.
Does it need debouncing?
Only if the sketch counts changes. Like any mechanical contact it bounces for a moment at each press, usually a few milliseconds; nobody has measured this one. A sketch that reads the level never notices. One that acts on each change should believe a new level only once it has held, 20 ms in the handbook's sketches.
The state is still on after a reset. Is that right?
Yes, and it is the reason to choose this block. The switch is a mechanical latch, so a reset or a power cut cannot move it. Read it in setup() and the sketch comes back in the state it was left in. If the program must be able to change the state itself, use the TK04 push button and a variable.
What is the NC pin for?
Nothing on this board. It is in no net at all. Every TinkerBlock block has the same four-pin header so the same cable fits all of them, and this block needs three of the four.

The latching button handbook

9 articles · about 40 minutes

This page is the reference: what the part is, what it is made of, and the questions people arrive already asking. The handbook is the walk — the same part in the order somebody actually meets it.

What is on the board

2 articles

Four pins, three of them wired, a switch that stays where you leave it, and the red light that says which way it is.

Why on reads HIGH

2 articles

The pull-down that holds SIGNAL at 0 V, the switch that lifts it to VCC, and why that makes VCC the one pin you cannot wire by habit.

Reading it

3 articles

The first read, then turning a level into an event, then the property no push button has: the position is still there after a reset.

Bounce, and when it reads wrong

2 articles

Why a switch that latches still chatters for a moment at every change, when that matters, and the short list of reasons a reading is wrong.

Lessons using TK05

Each one is a working build, not a snippet.

Edit this page — content/modules/latching-button.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Latching Button

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum