MSOE EE2905 / Mbed 2 deprecated ButtonInterrupt

Dependencies:   mbed

Fork of ButtonInterrupt by Sheila Ross

main.cpp

Committer:
rossatmsoe
Date:
2017-08-12
Revision:
0:df23bf5767ec

File content as of revision 0:df23bf5767ec:

#include "mbed.h"

// Declare that the USER_BUTTON will trigger an external interrupt mybutton
InterruptIn mybutton(USER_BUTTON);

DigitalOut myled(LED1);

// Function prototypes
void pressed();
void released();
  
int main()
{
    // Define the behavior of the interrupt on rising and falling edges
    mybutton.fall(&pressed);
    mybutton.rise(&released);
    
    // do nothing; the interrupt servicing functions do all the work
    while(1) {
        wait(1);
    }    
    
}

void pressed() {  // short flash when pressed
    myled = 1;
    wait(0.2);
    myled = 0;
}

void released() {  // long flash when released
    myled = 1;
    wait(1);
    myled = 0;
}