Allume/éteint la LED quand on appuie sur le bouton

Dependencies:   mbed

Fork of Allumage_LED by Valentin Dubois

main.cpp

Committer:
valdub
Date:
2014-05-15
Revision:
0:c72f09731dd4

File content as of revision 0:c72f09731dd4:

#include "mbed.h"

DigitalOut myled(LED1);
InterruptIn button(USER_BUTTON);
Timer debounce;

int i=0;

void toggle()
{
    if (debounce.read_ms() > 100) {
        i = !i; }
    debounce.reset();
}

int main() 
{
    myled = 0;
    button.rise( &toggle );
    debounce.start();
    
    while (1) 
    {
        myled = (i == true) ?1 :0;
    }
}