Writing / Dev Logs
Dev LogKaroKorry20.10.2026

How a button learns its own name

Every device on an I²C bus needs its own address, but I wanted all buttons to come out of the bag identical. So a new button only knows a shared "newcomer" address, and only answers on it while you hold it down. Ten new buttons can sit on the bus in silence, because only the one under your finger speaks. The controller gives it a free address, the button saves it to flash, flashes green three times and that's it.

At first a brand-new button wouldn't blink orange as it should; it acted as if it already had an address. The code treated a saved value of 0xFF as "empty", like on most similar chips. A couple of debug prints read live from the chip showed the truth: here, empty reads as 0x00. The button thought it had been given address zero.

Instead of swapping one magic value for another, the check now asks: does this look like an address I would actually hand out? Lesson learned: ten minutes of printing what is really happening beats an hour of reasoning about what should.

embeddedi2c