interrupt

Dependencies:   mbed

Committer:
florianjehannin
Date:
Wed Jan 18 10:22:36 2017 +0000
Revision:
0:a3c8e021fd64
interrupt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
florianjehannin 0:a3c8e021fd64 1 #include "mbed.h"
florianjehannin 0:a3c8e021fd64 2
florianjehannin 0:a3c8e021fd64 3 InterruptIn button(PB_13);
florianjehannin 0:a3c8e021fd64 4 DigitalOut led(LED2);
florianjehannin 0:a3c8e021fd64 5
florianjehannin 0:a3c8e021fd64 6 void flip() {
florianjehannin 0:a3c8e021fd64 7 led = !led;
florianjehannin 0:a3c8e021fd64 8 wait(0.1);
florianjehannin 0:a3c8e021fd64 9 }
florianjehannin 0:a3c8e021fd64 10
florianjehannin 0:a3c8e021fd64 11 int main() {
florianjehannin 0:a3c8e021fd64 12 button.mode(PullUp);
florianjehannin 0:a3c8e021fd64 13 wait(0.01);
florianjehannin 0:a3c8e021fd64 14 button.fall(&flip); // attach the address of the flip function to the rising edge
florianjehannin 0:a3c8e021fd64 15 led = 0;
florianjehannin 0:a3c8e021fd64 16 while(1) { // wait around, interrupts will interrupt this!
florianjehannin 0:a3c8e021fd64 17
florianjehannin 0:a3c8e021fd64 18 }
florianjehannin 0:a3c8e021fd64 19 }