mechanical key/Wiring it/03. The four pins
Wiring it · 03 of 9

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 pins
Show
Pins
4
Pins to wire
4
Pitch
2.54 mm
The switch's other side, with 10 kΩ to GND. Up, the resistor holds it LOW; down, the switch joins it to VCC and it reads HIGH. Set the pin to INPUT, not INPUT_PULLUP: the board already chose the direction.

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:

BoardBUTTONWS2812VCC
Arduino UnoD2D65V
ESP32GPIO 25GPIO 43V3
ESP32-S3GPIO 4GPIO 53V3
Raspberry Pi PicoGP15GP143V3

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

Which pin is which when the block is upside down?

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.

My TinkerBlock cable has four wires. Which goes where?

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.

Is WS2812 an input or an output?

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.

Where this goes next

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

Community

Questions about this product

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

Ask a question ↗

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.

Browse Modules and blocks on the forum →