使用 button 控制 LED

Dependencies:   mbed

main.cpp

Committer:
mbedschool
Date:
2015-02-14
Revision:
0:b38f3a86b62b

File content as of revision 0:b38f3a86b62b:

#include "mbed.h"
 
DigitalOut myled(LED1);
DigitalIn button(p21);
 
int main()
{
    while(1){
        if(button){
            myled = 1 ;
           
        }  
        else
            myled = 0;   
            
         wait(0.7); // simple debouncing      
    }
 
}