通过按键控制LED

Dependencies:   mbed

main.cpp

Committer:
Andthen
Date:
2015-12-05
Revision:
0:c3898039eff5

File content as of revision 0:c3898039eff5:

#include "mbed.h"
DigitalOut led1(LED1);
DigitalIn btn(USER_BUTTON);
int main()
{
    led1=0;
    while (1) {
        if (btn==0 ) {
            wait_ms(10);
            if (btn==0 ) {
                led1=!led1;
                while (btn==0);
            }
        }

    }


}