The program uses the BusOut Class to make a counter

Dependencies:   mbed

Fork of BusOut_HelloWorld by mbed_example

Committer:
shiyilei
Date:
Thu Oct 16 07:42:24 2014 +0000
Revision:
3:b83cb0af21b0
Parent:
2:76f66b714f20
Child:
4:c01479bfd551
learn the BusInOut class and use it to make a key_controlled counter

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shiyilei 3:b83cb0af21b0 1 /*************************************************
shiyilei 3:b83cb0af21b0 2 *file name : switch point
shiyilei 3:b83cb0af21b0 3 *creator:Jacob Shi
shiyilei 3:b83cb0af21b0 4 *Time:2014/10/16
shiyilei 3:b83cb0af21b0 5 *Description: uses to key to control the counter
shiyilei 3:b83cb0af21b0 6 *************************************************/
mbed_official 0:717993c337df 7 #include "mbed.h"
shiyilei 2:76f66b714f20 8 char data[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
shiyilei 3:b83cb0af21b0 9 char i=0;
shiyilei 3:b83cb0af21b0 10 BusInOut key(p5);
shiyilei 3:b83cb0af21b0 11 BusInOut portnum(p21,p22,p23,p24,p25,p26,p27,p28);
shiyilei 3:b83cb0af21b0 12 int main()
shiyilei 3:b83cb0af21b0 13 {
shiyilei 3:b83cb0af21b0 14 key.input();
shiyilei 3:b83cb0af21b0 15 portnum.output();
shiyilei 3:b83cb0af21b0 16 while(1)
shiyilei 3:b83cb0af21b0 17 {
shiyilei 2:76f66b714f20 18
shiyilei 3:b83cb0af21b0 19 portnum=0x00;
shiyilei 3:b83cb0af21b0 20 if(key==0)
shiyilei 3:b83cb0af21b0 21 {
shiyilei 3:b83cb0af21b0 22 wait_ms(10);
shiyilei 3:b83cb0af21b0 23 if(key==0)
shiyilei 3:b83cb0af21b0 24 {
shiyilei 3:b83cb0af21b0 25 while(!key);
shiyilei 3:b83cb0af21b0 26 portnum=data[i];
shiyilei 3:b83cb0af21b0 27 (i++)%10;
shiyilei 3:b83cb0af21b0 28 }
shiyilei 3:b83cb0af21b0 29
shiyilei 3:b83cb0af21b0 30 }
shiyilei 3:b83cb0af21b0 31
mbed_official 0:717993c337df 32 }
shiyilei 3:b83cb0af21b0 33 }