interrupt

Dependencies:   mbed

main.cpp

Committer:
kaushalpkk
Date:
2018-06-28
Revision:
0:7e26160770f8

File content as of revision 0:7e26160770f8:

#include "mbed.h"

DigitalOut led1(LED1);
DigitalOut led2(LED2);
InterruptIn button(p30);

void flip() {
    wait(0.5);    
    led2 = !led2;
    printf("Interrupted!!\n");
}
 
int main() {
    button.rise(&flip);  // attach the address of the flip function to the rising edge
    while(1) {
        led1 = !led1;
        wait(1);
    }
}