Part 4: Interrupts
~45-60 min
So far, all your code has been polling - checking the button state in a loop, reading sensors repeatedly. This works, but it's wasteful. The CPU spins constantly even when nothing is happening.
Interrupts let the hardware notify your code when something happens. The CPU can do other work (or sleep) until an event occurs.
What You'll Do
- Interrupt-driven button - configure the existing GPIO input button example to use interrupts instead of polling
- I/O Expander interrupt - use the TCA6424's INT output to detect input changes without polling over I2C