Skip to content

Commit

Permalink
Create readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
swharden committed Feb 25, 2018
1 parent 1afb853 commit 6d87a25
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ATTiny2313 2018-02-25 button interrupt/readme.md
@@ -0,0 +1,25 @@
# Button Press Launches Interrupt
Here a button (pulled high, grounded when pressed) causes an interrupt.

```C

#include <avr/interrupt.h>

ISR(INT0_vect){
// runs when the button is pressed
}

void SetupButton(){
MCUCR=(1<<ISC01); // falling edge of INT0 generates interrupt
GIMSK=(1<<INT0); // INT0 causes interrupt request
EIFR=(1<<INTF0); // INT0 change Interrupt Flag
PCMSK=(1<<PCINT1); // watch these pins
sei(); // enable global interrupts
}


int main(void){
SetupButton();
for(;;){}
}
```

0 comments on commit 6d87a25

Please sign in to comment.