Projet_elec / Mbed 2 deprecated btn_interrupt2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002  
00003 InterruptIn button(PB_13);
00004 DigitalOut led(LED2);
00005  
00006 void flip() {
00007     led = !led;
00008     wait(0.1);
00009 }
00010  
00011 int main() {
00012     button.mode(PullUp);
00013     wait(0.01);
00014     button.fall(&flip);  // attach the address of the flip function to the rising edge
00015     led = 0;
00016     while(1) {           // wait around, interrupts will interrupt this!
00017         
00018     }
00019 }