Skip to content

Instantly share code, notes, and snippets.

@matael
Created May 4, 2014 20:11
Show Gist options
  • Save matael/11523159 to your computer and use it in GitHub Desktop.
Save matael/11523159 to your computer and use it in GitHub Desktop.
//interruption
// on arrete ce qu'on faisais pour aller traiter l'évenement
const byte LED = 13;
const byte BUTTON = 2;
volatile int led_state = LOW;
// Interrupt Service Routine (ISR)
void pinChange ()
{
led_state = !led_state;
digitalWrite(LED, led_state);
} // end of pinChange
void setup () {
pinMode (LED, OUTPUT); // so we can update the LED
digitalWrite (BUTTON, HIGH); // internal pull-up resistor
attachInterrupt (0, pinChange, CHANGE); // attach interrupt handler
} // end of setup
void loop ()
{
// loop
// doing
// nothing
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment