Emery Premeaux / Mbed 2 deprecated Examples

Dependencies:   mbed SDFileSystem

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Button_Interrupt.cpp Source File

Button_Interrupt.cpp

00001 
00002 #ifdef  COMPILE_Button_Interrupt
00003 
00004 
00005 InterruptIn button(USER_BUTTON);
00006 
00007 DigitalOut led(LED1);
00008 
00009 double delay = 0.5; // 500 ms
00010 
00011 void pressed()
00012 {
00013     delay = 0.1; // 100 ms
00014 }
00015 
00016 void released()
00017 {
00018     delay = 0.5; // 500 ms
00019 }
00020 
00021 int main()
00022 {
00023     // Assign functions to button
00024     button.fall(&pressed);
00025     button.rise(&released);
00026 
00027     while (1) {
00028         led = !led;
00029         wait(delay);
00030     }
00031 }
00032 
00033 #endif