Today I learned to always question your assumptions, even the most basic ones.

I forgot how the internal contacts of a pushbutton switch were connected. Somehow I thought that because they can straddle the middle of a breadboard, they are meant to connect left to right.

But of course that does not work for anywhere else on the breadboard, where the horizontal strips are connected. After a few hours of debugging via prints (I thought it was in my logic, or that I didn’t understand static variables), I had to pullout the big guns and go into gdb , which I usually try to avoid.

I quickly found that buttonState was 0, and not 1 as expected for the INPUT_PULLUP Screenshot 2023-08-20 at 12.37.39 PM

Then of course I looked for the schematic of the pushbutton: Screenshot 2023-08-20 at 12.35.05 PM