learn the Busin Class to realize that 2 keys control the lights
Dependencies: mbed
Fork of BusIn_HelloWorld by
Diff: main.cpp
- Revision:
- 3:fa8283d98f9a
- Parent:
- 2:b22e7d5a6872
--- 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