mechanical key/Wiring it/04. One VCC, two jobs
Wiring it · 04 of 9

One VCC, two jobs

VCC is the far side of the key, so a press puts VCC on your pin; and it is the LED's supply, which the LED's sheet wants from 3.5 V. On an Uno 5V does both. Beside a 3.3 V board the pin wins: VCC on 3V3, and the LED runs under its rating.

The key's job

The switch joins VCC to BUTTON. While the key is down, BUTTON is VCC: your pin receives whatever voltage VCC has, with nothing on the board in between. That is the TK04's rule and it holds here: VCC must be the voltage your board's pins run at.

The LED's job

The same pin powers the WS2812. XINGLIGHT's sheet gives it a supply of 3.5 to 5.5 V, and says it is fully working from 4.5 V. So the LED would like 5 V.

One VCC, two jobs
Your board
Wiring
Pin, key down
3.30 V
LED supply
3.30 V
Data HIGH needs
1.65 V
The rule: VCC on 3V3. A press gives the pin 3.3 V, exactly what it runs at. The cost is the light: 3.3 V is under the LED's 3.5 V minimum, so the sheet promises nothing. It usually still lights, red best, with green and blue dimmer, because those two need the most voltage.

On an Uno, no conflict

The Uno's pins run at 5 V. VCC on 5V gives the key a 5 V HIGH, which is what the pin expects, and the LED its full supply. Both jobs, one wire.

On a 3.3 V board, the pin wins

An ESP32, an ESP32-S3 and a Pico run their pins at 3.3 V, and none of them is built to take 5 V. Put VCC on 3V3. The key then works exactly as it should, and the cost falls on the light: 3.3 V is under the LED's 3.5 V minimum, so its sheet promises nothing.

In practice a WS2812 usually still lights at 3.3 V. Red holds up best, and green and blue fade first, because their LED chips need the most voltage. Nobody has measured this block at 3.3 V, so take that as what to expect rather than a figure. The sketches in this book start with red for that reason.

The data line is not the problem. This LED reads a HIGH on its data pin from half its own supply: 1.65 V on 3.3 V, 2.5 V on 5 V. A 3.3 V pin clears either comfortably.

Full colour on a 3.3 V board

If the colours matter, give each job its own voltage. Put VCC on the 5V pin (VBUS on a Pico) for the LED, and bring BUTTON to your pin through two resistors: 10 kΩ from BUTTON to the pin, and 20 kΩ from the pin to GND. A press then gives the pin two thirds of VCC: 3.33 V from 5.0 V, 3.07 V from an ESP32's 4.6 V. With the key up, the resistors hold the pin at 0 V.

That is arithmetic, not a bench test. The WS2812 wire needs nothing: a 3.3 V pin drives it directly at either supply.

When it does not work

Can I put VCC on 5V next to an ESP32 for a brighter LED?

Not on its own. Every press would join 5 V, or about 4.6 V from an ESP32's 5V pin, straight to a GPIO rated for 3.3 V. It reads HIGH and seems fine while the pin is past its rating. If you want 5 V for the LED, add the two-resistor divider on BUTTON this article describes.

On 3V3 the LED lights. Is that within spec?

No. The sheet's minimum supply is 3.5 V and it calls the LED fully working from 4.5 V. Below that it promises nothing. Most WS2812s still light at 3.3 V, red best, green and blue dimmer, but a colour that looks wrong at 3.3 V is not a fault.

Does the data line need a level shifter?

No. This LED counts its data input HIGH from half its supply: 1.65 V at 3.3 V, 2.5 V at 5 V. A 3.3 V pin clears both. It is a lower threshold than the TK33's LEDs, which want 0.7 of their supply.

Why not a 5 V board and 3.3 V logic both?

An Uno does not need a choice: its pins run at 5 V, so VCC on 5V gives the key the right HIGH and the LED its full supply. The conflict is only on 3.3 V boards, where one pin cannot be 5 V for the LED and 3.3 V for the input.

Where this goes next

The 10 kΩ pull-down, and why a sketch that waits for LOW gets this key backwards.

Pressed reads HIGH →

Edit this page — content/books/mechanical-key/one-vcc-two-jobs.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 →