Internal Interrupts
Timer
Timer2
The “Arduino language” supports the attachInterrupt() function.
Two external Hardware Interrupts
INT0 and INT1 are mapped to Arduino pins 2 and 3. These interrupts can be set to trigger on RISING or FALLING signal edges, or on low level.
noInterrupts(); // disable all interrupts
interrupts(); // enable all interrupts
HARDWARE INTERRUPT EXAMPLE
int pin = 2; //define interrupt pin to 2volatile int state = LOW; // To make sure variables shared between an ISR//the main program are updated correctly,declare them as volatile.void setup() { pinMode(13, OUTPUT); //set pin 13 as output attachInterrupt(digitalPinToInterrupt(pin), blink, CHANGE); //interrupt at pin 2 blink ISR when pin to change the value} void loop() { digitalWrite(13, state); //pin 13 equal the state value} void blink() { //ISR function state = !state; //toggle the state when the interrupt occurs}
Understanding Arduino Interrupts | Hardware, Pin Change & Timer Interrupts