by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Dependencies:   mbed

main.cpp

Committer:
robt
Date:
2013-05-24
Revision:
0:b3db09a98287

File content as of revision 0:b3db09a98287:

/* Program Example 9.1: Simple interrupt example. External input causes interrupt, while led flashes  
                                                                            */
#include "mbed.h"
InterruptIn button(p5);    //define and name the interrupt input
DigitalOut led(LED1);       
DigitalOut flash(LED4);

void ISR1() {                 //this is the response to interrupt, i.e. the ISR
  led = !led;
}

int main() {
  button.rise(&ISR1);     // attach the address of the ISR function to the                               
                                              // interrupt rising edge
  while(1) {              // continuous loop, ready to be interrupted
    flash = !flash;
    wait(0.25);
  }
}