use the PortInOut class to make a key_controlled counter

Dependencies:   mbed

Fork of PortInOut_HelloWorld by mbed official

Committer:
shiyilei
Date:
Fri Oct 17 01:29:32 2014 +0000
Revision:
2:7e1bc5947174
Parent:
0:018ca8a43b33
use the PortInOut Class to make a key_controlled counnter

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shiyilei 2:7e1bc5947174 1 /*************************************************
shiyilei 2:7e1bc5947174 2 *file:time counter
shiyilei 2:7e1bc5947174 3 *creator:JacobShi
shiyilei 2:7e1bc5947174 4 *Time:2014/10/16
shiyilei 2:7e1bc5947174 5 * Description: uses the portInOut to make a keycrolled couter
shiyilei 2:7e1bc5947174 6 **************************************************/
shiyilei 2:7e1bc5947174 7 #include "mbed.h"
shiyilei 2:7e1bc5947174 8 char data[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
shiyilei 2:7e1bc5947174 9 PortInOut lednumber(Port0,0x000000ff);
shiyilei 2:7e1bc5947174 10 PortInOut keycontrol(Port1,0x00000001);
shiyilei 2:7e1bc5947174 11 int i=0;
mbed_official 0:018ca8a43b33 12 int main() {
shiyilei 2:7e1bc5947174 13 lednumber.output();
shiyilei 2:7e1bc5947174 14 keycontrol.input();
shiyilei 2:7e1bc5947174 15 while(1)
shiyilei 2:7e1bc5947174 16 {
shiyilei 2:7e1bc5947174 17 if(!keycontrol)
shiyilei 2:7e1bc5947174 18 {
shiyilei 2:7e1bc5947174 19 wait_ms(10);
shiyilei 2:7e1bc5947174 20 if(!keycontrol)
shiyilei 2:7e1bc5947174 21 {
shiyilei 2:7e1bc5947174 22 while(!keycontrol);
shiyilei 2:7e1bc5947174 23 lednumber=data[i];
shiyilei 2:7e1bc5947174 24 (i++)%10;
shiyilei 2:7e1bc5947174 25 }
shiyilei 2:7e1bc5947174 26
shiyilei 2:7e1bc5947174 27 }
shiyilei 2:7e1bc5947174 28
mbed_official 0:018ca8a43b33 29 }
mbed_official 0:018ca8a43b33 30 }