When it reads wrong
The red LED splits every wrong reading in two. If it follows the switch, the block is fine and the problem is between SIGNAL and your sketch. If it never lights, the problem is VCC, GND or the header, before the sketch is involved at all.
Five symptoms
Pick what you see. The ringed part of the board is where to look first, and the list beside it is the order to check in, by how often each one is the answer.
LOW, and the LED never lights
The switch has nothing to connect. VCC is unwired, or on the wrong pin of your board, so closing the switch joins SIGNAL to nothing and the pull-down holds it at 0 V. The LED is fed through the switch from the same VCC, so it stays dark too. Then count from the square pad: one pin over puts VCC on NC, which goes nowhere. Then GND.
LOW, and the LED lights
The block is fine: VCC arrived and the switch is on. The sketch is reading a
different pin. SWITCH_PIN is a GPIO number, the one printed beside the pin on
your board, not a count along the header. On an ESP32 dev board, the pin marked
25 is GPIO 25 wherever it sits on the edge.
Always HIGH
If the LED is lit, the switch is latched on and HIGH is right. Press it once.
If the LED is dark and the pin still reads HIGH, SIGNAL is not reaching it and
something else holds it up: most often INPUT_PULLUP in the sketch, which
keeps an unconnected pin HIGH. Use INPUT. Or SIGNAL is on a supply pin
rather than a GPIO.
Random
A pin connected to nothing floats and reads whatever it picks up. The block's pull-down only holds a pin it is wired to, so a SIGNAL wire that has come out of its row gives random readings. So does a missing GND: the pull-down then leads nowhere. Reseat the wires before touching the sketch.
Counts double
One press, two or more changes. That is bounce at each change: the sketch is believing the level before it has settled. Accept a new level only once it has held for 20 ms, as the change sketch does.
When it does not work
Wire GND and VCC only, and press the switch. The LED should light and stay lit, and go out at the next press. If it does, the switch, the LED and the power are all fine, and anything still wrong is SIGNAL's wire or the sketch.
Look for a wire that has come out of the breadboard, VCC first, since without it the block reads LOW in both positions. The right-angle header pins lie flat and a cable's weight can lift them out of a row. Press the block back in, or use a TinkerBlock cable.
The pins used for flash memory, which the chip cannot spare, and the strapping pins, the ones read at reset to choose how the chip boots: the block's pull-down, or a switch left on, holds such a pin at a level it may not expect. GPIO 25 on an ESP32 and GPIO 4 on an ESP32-S3 are clear of both.
Rarely, and it is the last thing to suspect. Its drawing rates it for at least 50,000 cycles. If the LED does not follow the switch with VCC and GND wired straight to your board's supply pins, and the header is counted from the square pad, then suspect the switch.
Forty-odd blocks. The latching button is the one that remembers where you left it.
Back to the blocks →Edit this page — content/books/latching-button/when-it-reads-wrong.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Latching Button
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.