five-direction joystick/Using it/10. When a reading is wrong
Using it · 10 of 10

When a reading is wrong

Six ways a TK94 reading goes wrong, and the place to look for each. Almost all of them are the wiring or the sketch's idea of VCC: a missing VCC reads 0, a digital pin reads nonsense, the wrong supply names pushes wrong, and a sketch that trusts every reading sees extra pushes on letting go.

What it does, and where to look

What it does, and where to look
What it does
With VCC unconnected the ladder has nothing at its top, and R14 holds SIGNAL at 0 V whatever you push. If VCC is in, SIGNAL is on a different pin from the one SIGNAL_PIN names, or on NC, the third hole from the square pad, which goes nowhere.

Pick what you are seeing. The board rings where to look, and the verdict says why.

Print the number first

Nearly every fault shows in the raw reading, so run the first read sketch before anything else and push each way. With the right wiring an Uno prints about 0, 111, 182, 273, 444 and 1000 thousandths for nothing, up, press, left, down and right; an ESP32 prints right a little under 1000, often about 940.

  • All 0: VCC is missing, or SIGNAL is on the wrong hole.
  • Random, with nothing pressed: SIGNAL is not reaching the pin read.
  • The right order, but every number about two thirds of the book's: an Uno with VCC on 3V3.
  • The right numbers, the wrong names: the block is held another way round. The names are for the header on the left.
  • Extra pushes when letting go: the sketch trusts every reading.
  • A press nobody made: a diagonal from left to up, which reads as a press.

The one that is not a fault

That last one is the ladder working as designed. Up and left together settle between the press's level and left's, on the press's side of the line; two at once shows why. A menu that must not select by accident should ask for the press to be held a little longer than a thumb's roll.

When it does not work

Everything reads 0.

VCC is not connected, or SIGNAL is on NC. With no VCC the ladder has no top and R14 holds SIGNAL at 0 whatever you push. Count from the square pad: GND, VCC, NC, SIGNAL.

Every push is named as the one below it.

VCC is not what the sketch divides by. On an Uno it must be on 5V, not 3V3; on an ESP32, ESP32-S3 or Pico on 3V3. Print the raw thousandths and compare them with the book's: about 111, 182, 273, 444 and 1000.

Only right does anything.

SIGNAL is being read with digitalRead, or it is on a pin with no ADC. A digital input calls right HIGH and the other four LOW. Use analogRead on an analog pin: A0 on an Uno, GPIO 34 on an ESP32, GPIO 4 on an ESP32-S3, GP26 on a Pico.

Where this goes next

A thumb stick with two axes and a click, and six more buttons on one analog pin.

Slim Joystick →

Edit this page — content/books/five-direction-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 ↗

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 →