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

Dependencies:   mbed

Fork of BusIn_HelloWorld by mbed official

main.cpp

Committer:
shiyilei
Date:
2014-10-16
Revision:
3:fa8283d98f9a
Parent:
2:b22e7d5a6872

File content as of revision 3:fa8283d98f9a:

/***************************************************************
*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); 
DigitalOut myled1(LED1);
DigitalOut myled2(LED2);
int main() {
    while(1) {
        switch(nibble) {
            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; 
        }
    }
}