🔌Interrupt (Hardware)
Also known as Hardware Interrupt, Interrupt Service Routine, attachInterrupt
A signal that makes a chip drop its work at once and deal with an event.
Think of it like
It is like a doorbell. You do not keep checking the door, because the bell tells you.
Example
On an Arduino Uno, only pins 2 and 3 can trigger an interrupt. Jack wires a button to pin 2, and each press runs his handler right away.
Why it matters
Events like a button press can be over in a blink. An interrupt makes sure the chip never misses one.
Definition
Example code
cpp
attachInterrupt(digitalPinToInterrupt(2), onPress, FALLING);Common mistake
Key takeaways
- 1Instant. The chip stops what it is doing.
- 2Short handler. Do the least, then return.
- 3No polling. No need to keep checking.