Created
May 4, 2014 20:11
-
-
Save matael/11523159 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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