The four pins
GND, VCC, WS2812 and BUTTON, left to right with the key up, GND on the square pad. All four are wired: there is no NC pin on this block. BUTTON is an input to your board, WS2812 an output from it.
Count from the square pad
The four holes are identical except one: GND's pad is square. Everything else is counted from it. With the key facing you and the header at the bottom, left to right: GND, VCC, WS2812, BUTTON. The front prints the names; the back prints none, and from the back the order is mirrored.
The header's own numbering runs the other way, so in the net list BUTTON is U10 pin 1 and GND is pin 4. That only matters if you read the schematic.
Two directions
BUTTON is a signal the block sends to your board: HIGH while the key is
down, LOW while it is up. Your pin is an input, set with
pinMode(pin, INPUT).
WS2812 is a signal your board sends to the block: a stream of short
pulses that sets the LED's colour. Your pin is an output, and a library
drives it; you never write it with digitalWrite.
VCC and GND feed both halves, which is why neither can be left off even when you use only one half. Which voltage VCC gets is the one decision this block asks of you, and the next article is about it.
Pins that work
The book uses the same pins everywhere, taken from the TK04 and TK33 books so the blocks can share a board:
| Board | BUTTON | WS2812 | VCC |
|---|---|---|---|
| Arduino Uno | D2 | D6 | 5V |
| ESP32 | GPIO 25 | GPIO 4 | 3V3 |
| ESP32-S3 | GPIO 4 | GPIO 5 | 3V3 |
| Raspberry Pi Pico | GP15 | GP14 | 3V3 |
None of the ESP32 pins is a strapping pin, a flash pin or input-only, so the block cannot stop the board from starting. Any other plain GPIO works too.
When it does not work
Find the square pad; it is GND. From it, going across the header: GND, VCC, WS2812, BUTTON. From the back the square pad is on the right, and the order runs right to left. The back prints no pin names.
The cable keeps the header's order, so the wire on the square pad's side is GND. Follow each wire to your board and check it against the four lines in the first press article before powering up.
On your board it is an output: your pin sends colour data to the LED. BUTTON is the other way, an input your pin reads. Swapped, nothing works, and worse: a press joins VCC straight to the pin that is driving the LED line, which shorts that pin whenever it is LOW. Check the two wires before powering up.
Why VCC is 3V3 beside an ESP32 or a Pico, and what that costs the LED.
One VCC, two jobs →Edit this page — content/books/mechanical-key/the-four-pins.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Mechanical Key and LED
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.