使用 button 控制 LED

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
mbedschool
Date:
Sat Feb 14 05:48:52 2015 +0000
Commit message:
update

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r b38f3a86b62b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Feb 14 05:48:52 2015 +0000
@@ -0,0 +1,19 @@
+#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      
+    }
+ 
+}
diff -r 000000000000 -r b38f3a86b62b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Feb 14 05:48:52 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e188a91d3eaa
\ No newline at end of file