slim joystick/Using it/11. When a reading is wrong
Using it · 11 of 11

When a reading is wrong

There is no LED on this board, so the numbers are the only witness. Six symptoms cover nearly everything: the stick stuck, no button reading, the wrong button named, KEY backwards, a stick that creeps, and two buttons that read as one. Most are a wire; one is the circuit working as designed.

No light to go by

Most blocks have an LED that says they have power. This one has none, so the first sketch's printout is the whole diagnosis. Run the first read and look at what it says with the stick let go and nothing pressed: X and Y near the middle, KEY 0, BTNS 0 mV and none. Anything else points at one of these.

When a reading is wrong
What it does
X and Y both near 0, or both at the top, whatever the stick does: the track has no supply, or no ground, so the wiper has nothing to divide. Check 3V3 and GND first, then that X and Y go to analog pins, then count from the square pad: GND is the right-hand end seen from the parts side.

A wire, usually

X and Y stuck at 0 or at the top means the tracks are missing their supply or their ground. Every reading on this board is a share of 3V3, so 3V3 and GND come first.

No button reads means BTNS is on the wrong pin, or read with digitalRead. U11 is the test: it joins BTNS straight to 3V3, so it should read the top of the range on any analog pin.

The wrong button named almost always means the header's 3V3 pin is on 5V. Every level rises by half and crosses the line above it: U5 reads as U10, U6 as U7. On an ESP32 or a Pico, 5V there also puts 5 V on an analog pin, which it is not built to take. Move it to 3V3.

KEY backwards or stuck HIGH is the pin mode. The board has its own pull-down, so KEY is INPUT and reads HIGH while clicked.

Not a fault

Creeping when let go is a centre that was measured with a thumb on the stick, or never measured at all. Reset with the stick let go, and keep a dead zone.

Two buttons that read as one is the ladder. The one nearer BTNS wins, the other is invisible, and nothing in software can find it. One button at a time explains why, and what to use instead.

When it does not work

Nothing reads at all, on any pin.

Check 3V3 and GND before anything else. Every reading on this board is a share of 3V3, so without it the stick, the buttons and KEY all read 0. Count from the square pad: GND is the right-hand end with the parts up and the header at the top.

Everything worked until I moved it to another board.

The pin numbers changed. Every sketch in this book lists all four boards' pins in one comment line: Uno A0 A1 A2 2, ESP32 34 35 32 25, ESP32-S3 4 5 6 7, Pico 26 27 28 15, in the order X, Y, BTNS, KEY. On an Uno, also set FULL_SCALE_MV to 5000.

It worked on my desk and not on the robot.

A long cable or a motor on the same supply adds noise, and the closest buttons, U8 and U6, are only 0.11 V apart. Keep the cable short, give the motors their own supply, and believe a button only when two readings in a row agree.

Where this goes next

The pins, the levels and the wiring on one page, for when you only need to look something up.

The Slim Joystick reference page

Edit this page — content/books/slim-joystick/when-a-reading-is-wrong.mdx

Community

Questions about this product

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

Ask a question ↗

Slim 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