button trigger interrupt 20160528

Dependencies:   mbed

Fork of Nucleo_read_button_interrupt by joseph chen

main.cpp

Committer:
ittraining
Date:
2016-05-28
Revision:
2:4103c09a0f63
Parent:
1:19e910fda737

File content as of revision 2:4103c09a0f63:

#include "mbed.h"
 
InterruptIn mybutton(USER_BUTTON);
DigitalOut myled(LED1);
 
float delay = 1.0; // 1 sec
 
void pressed_down()
{
    if (delay == 1.0)
        delay = 0.2; // 200 ms
    else
        delay = 1.0; // 1 sec
}


 
int main()
{
    mybutton.fall(&pressed_down);
   // mybutton.rise(&pressed_down);
    while (1) {
        myled = !myled;
        wait(delay);
    }
}