A ladder of resistors
Five 10 kΩ resistors in a chain from VCC to GND make four joins at four voltages. Each push joins SIGNAL to one of them, or to VCC itself for right. A sixth 10 kΩ from SIGNAL to GND loads whichever join is picked, so the levels come out as a ninth, two elevenths, three elevenths, four ninths and all of VCC, not the tidy fifths the chain alone would give.
A chain with four joins
R7, R9, R10, R11 and R12 run in a chain from VCC to GND, 50 kΩ in all. A small current, VCC over 50 kΩ, flows through it all the time, and each join between two resistors sits at its own voltage: four fifths of VCC below R7, three fifths below R9, and so on down.
The switch's common pin is SIGNAL. Each push joins it to one point:
| Push | Joined to | Alone | With R14 |
|---|---|---|---|
| Right | VCC | 1 | 1 |
| Down | below R7 | 4/5 | 4/9 |
| Left | below R9 | 3/5 | 3/11 |
| Press | below R10 | 2/5 | 2/11 |
| Up | below R11 | 1/5 | 1/9 |
Why not fifths
R14, 10 kΩ from SIGNAL to GND, is there so SIGNAL rests at 0 V. But once a push joins SIGNAL to the chain, R14 is a second path to GND from that join, in parallel with the resistors below it. That lowers the join's voltage.
For a join with a resistors above it and b below (a + b = 5), SIGNAL is VCC × b / (5 + a × b). Down, one above and four below, is 4 / 9 of VCC; left, two and three, is 3 / 11. Pick a push in the figure and compare "Without R14" with the reading to see the difference.
It does no harm. The levels are still all different and still in the same order, up lowest and right highest, and a sketch only needs them to be different.
What it costs
The chain takes VCC over 50 kΩ whether you touch it or not: 66 µA at 3.3 V, 0.1 mA at 5 V. A push adds a little. Right adds the most, VCC across R14: 0.33 mA at 3.3 V for as long as it is held.
When it does not work
The fifths are right for the chain on its own. R14 hangs 10 kΩ from SIGNAL to GND, in parallel with the part of the chain below the join, and pulls every level down: down is 0.44 of VCC, not 0.6. Measure with a meter and you will see the loaded numbers.
With nothing pressed SIGNAL is joined to nothing but R14 and C3, both to GND. The chain is still there and still carries its small current, but no contact connects it to SIGNAL.
Yes, between SIGNAL and GND with VCC connected: about 0.37, 0.60, 0.90, 1.47 and 3.30 V at 3.3 V for up, press, left, down and right. A meter's own input is megohms, far too high to move the levels.
The lines a sketch draws between the levels, and how much room there is.
Telling them apart →Edit this page — content/books/five-direction-joystick/a-ladder-of-resistors.mdx
Questions about this product
See what other owners have asked, and read their solutions.
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.