five-direction joystick/Wiring it/04. VCC sets the top
Wiring it · 04 of 10

VCC sets the top

A push to the right joins SIGNAL straight to VCC, so whatever VCC is, your analog pin gets. VCC goes to your board's logic voltage: 5V on an Uno, 3V3 on an ESP32, ESP32-S3 or Pico. The page this replaced let any board use either supply; the wrong one puts 5 V on a 3.3 V pin, or misreads four pushes out of five.

Right is VCC

VCC sets the top
Your board
VCC wired to
Right puts
5.00 V
Pin rated
3.3 V
Named right
2 of 5
Over the limit. Right joins SIGNAL to VCC, so every push to the right puts 5.0 V on GPIO 34, a pin rated for 3.3 V. The other four levels are wrong too: the sketch divides by 3.3 V, so left, press, up read as their neighbours. VCC to 3V3.

Right's contact joins SIGNAL to the top of the ladder, which is VCC itself. So while the cap is pushed right, the analog pin gets exactly what VCC is. On an ESP32, an ESP32-S3 or a Pico, pins are rated for 3.3 V: VCC on 5V puts 5 V on one each time you push right.

Pick an ESP32 and 5V in the figure. Right goes over the pin's limit, and the other four are misnamed as well, because the sketch expects 3.3 V at the top.

A fraction of what, exactly

Every level is a fraction of VCC: down is four ninths of it, whatever VCC is. The sketch knows the fractions and needs to know what they are fractions of.

  • An Uno and a Pico measure against their own supply. With VCC on that same supply, a reading over 1023 is the fraction directly, and a USB port that gives 4.8 V instead of 5 changes nothing.
  • An ESP32 and an ESP32-S3 measure against a reference inside the chip. The sketch asks for millivolts and divides by 3300, so VCC must be the 3V3 pin.

Get it the wrong way round on an Uno, VCC on 3V3, and nothing is damaged but the levels are two thirds of what the sketch expects: down reads as left, left as the press, the press as up, and right as down.

The rule

VCC goes to your board's own logic voltage. It is the same rule as the TK96's, for the same reason: a switch on the block puts VCC on your pin.

When it does not work

I had VCC on 5V with an ESP32. Is it damaged?

Perhaps not, but do not keep doing it. Every push to the right joined a pin rated for 3.3 V to 5 V through nothing but the contact. Move VCC to 3V3, then check the pin still reads: push each way and compare with the numbers in the first-read sketch.

On an Uno with VCC on 3V3, down reads as left.

Every level is two thirds of what the sketch expects, because the Uno measures against its own 5 V. Move VCC to 5V. On an Uno that is both safe and right: SIGNAL never goes over the 5 V the pin runs at.

Does it matter that my USB gives 4.8 V, not 5?

Not on an Uno. With VCC on the Uno's own 5V pin, the ladder and the ADC share one supply, and every level is the same fraction of it. The sketch divides by the ADC's full scale, so the readings do not move.

Where this goes next

Where the five voltages come from, and why they are not tidy fifths.

A ladder of resistors →

Edit this page — content/books/five-direction-joystick/vcc-sets-the-top.mdx

Community

Questions about this product

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

Ask a question ↗

Five-Direction Joystick

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 →