Notes
How to use Arduino interrupts
Interrupt pins on different boards:
Interrupt | 0 | 1 | 2 | 3 | 4 | |
Uno | 2 | 3 | ||||
Mega 2560 | 2 | 3 | 21 | 20 | 19 | 18 |
Leonardo | 3 | 2 | 0 | 1 | 7 |
void setup() {
attachInterrupt(1, doSomething, CHANGE); // LOW|CHANGE|RISING|FALLING|HIGH
}
void loop() {
// ...
}
void doSomething() {
// ...
}