five-direction joystick/How it works/05. A ladder of resistors
How it works · 05 of 10

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

A ladder of resistors
Push
VCC
SIGNAL
0.90 V
Without R14
1.98 V
From VCC
0.120 mA
Left joins SIGNAL to the point 2 resistors below VCC. On its own that point would sit at three fifths of VCC, 1.98 V; R14 hangs 10 kΩ off it and pulls it down to 0.90 V. Different for every push, which is all the sketch needs.

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:

PushJoined toAloneWith R14
RightVCC11
Downbelow R74/54/9
Leftbelow R93/53/11
Pressbelow R102/52/11
Upbelow R111/51/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

I worked it out as fifths of VCC and the readings are lower.

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.

Why does it rest at 0 and not somewhere in the middle?

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.

Could I read it with a multimeter instead?

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.

Where this goes next

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

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 →