The program uses the BusInout Class to make a key_controlled counter from 0-9

Dependencies:   mbed

Fork of BusInOut_HelloWorld by mbed official

Committer:
shiyilei
Date:
Thu Oct 16 07:49:50 2014 +0000
Revision:
2:e9a810015812
Parent:
1:075e57eccf3a
learn the BusInOut Class to make a key-controlled program

Who changed what in which revision?

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