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

Dependencies:   mbed

Fork of BusIn_HelloWorld by mbed official

Committer:
shiyilei
Date:
Thu Oct 16 07:34:46 2014 +0000
Revision:
3:fa8283d98f9a
Parent:
2:b22e7d5a6872
Learn the BusIn class to realize a program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shiyilei 3:fa8283d98f9a 1 /***************************************************************
shiyilei 3:fa8283d98f9a 2 *file name : key control
shiyilei 3:fa8283d98f9a 3 *Time :2014/10/16
shiyilei 3:fa8283d98f9a 4 *Creator:JacobShi
shiyilei 3:fa8283d98f9a 5 * Description: open the keyx the LEDx is ON
shiyilei 3:fa8283d98f9a 6 ****************************************************************/
mbed_official 0:5e474ece410b 7 #include "mbed.h"
shiyilei 3:fa8283d98f9a 8 BusIn nibble(p5, p6);
shiyilei 3:fa8283d98f9a 9 DigitalOut myled1(LED1);
shiyilei 3:fa8283d98f9a 10 DigitalOut myled2(LED2);
mbed_official 0:5e474ece410b 11 int main() {
mbed_official 0:5e474ece410b 12 while(1) {
mbed_official 0:5e474ece410b 13 switch(nibble) {
shiyilei 3:fa8283d98f9a 14 case 0x01: myled1=1;myled2=0; break; /*p5 is high*/
shiyilei 3:fa8283d98f9a 15 case 0x02: myled2=1;myled1=0;break; /*p6 is high*/
shiyilei 3:fa8283d98f9a 16 case 0x03: myled2=1;myled1=1;break;
shiyilei 3:fa8283d98f9a 17 case 0x00: myled2=0;myled1=0;break;
shiyilei 3:fa8283d98f9a 18 default: break;
mbed_official 0:5e474ece410b 19 }
mbed_official 0:5e474ece410b 20 }
mbed_official 0:5e474ece410b 21 }