So, it turns out there’s such a thing as a pull-up resistor that pulls a pin away from ground so that when the pin is shorted to ground using, say a micro-switch connected to a valve rope on a water tower, the microcontroller can detect the change. Without the pull-up resistor, the input is said to be floating, which is to say it is whatever it wants to be, and in particular it might be just about any voltage at all once field effects of adjacent wires that you spent a pleasant evening of camaraderie and cookies neatly soldering to a project board are taken into account. If those field effects are especially pernicious, it might look like switches that ought to be open are closed, or switches that ought to be closed are open, and that can cause an entire weekend soldering and unsoldering the project board, completely negating that very pleasant evening of camaraderie and cookies and replacing it with 48 hours of blue-aired frustration.
Then, by chance, when the very notion of pull-up resistors is discovered and programmed, there could be even more head-scratching because they don’t appear to do a damned thing, and switches that ought to be open are still closed, and switches that ought to be closed are still open. Finally, when the whole project is about to go on permanent hiatus by being violently embedded into a semi-distant wall, it emerges that not all pins on an ESP32 actually have internal resistors. In particular, there are four – pins 34,35,36,39 – that don’t, but what those four unresisting pins do is shout how unlucky it was to have randomly chosen pins 34 and 36 to gather the input from the only two switches that matter in this circuit.
https://pembroke87.ca/2024/09/16/back-to-the-breadboard/