learn the Busin Class to realize that 2 keys control the lights

Dependencies:   mbed

Fork of BusIn_HelloWorld by mbed official

Files at this revision

API Documentation at this revision

Comitter:
shiyilei
Date:
Thu Oct 16 07:34:46 2014 +0000
Parent:
2:b22e7d5a6872
Commit message:
Learn the BusIn class to realize a program

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b22e7d5a6872 -r fa8283d98f9a main.cpp
--- a/main.cpp	Sun Sep 21 17:56:02 2014 +0000
+++ b/main.cpp	Thu Oct 16 07:34:46 2014 +0000
@@ -1,12 +1,21 @@
+/***************************************************************
+*file name :  key control
+*Time :2014/10/16
+*Creator:JacobShi
+* Description: open the keyx the LEDx is ON 
+ ****************************************************************/
 #include "mbed.h"
-
-BusIn nibble(p5, p6, p18, p11); // change pins according to platform
-
+BusIn nibble(p5, p6); 
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
 int main() {
     while(1) {
         switch(nibble) {
-            case 0x3: printf("Hello!\n"); break; // p5 and p6 are 1
-            case 0x8: printf("World!\n"); break; // p11 is 1
+            case 0x01: myled1=1;myled2=0; break; /*p5 is high*/
+            case 0x02: myled2=1;myled1=0;break; /*p6 is high*/
+            case 0x03: myled2=1;myled1=1;break;
+            case 0x00: myled2=0;myled1=0;break;
+            default: break; 
         }
     }
 }
\ No newline at end of file