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

Dependencies:   mbed

Fork of BusInOut_HelloWorld by mbed official

Files at this revision

API Documentation at this revision

Comitter:
shiyilei
Date:
Thu Oct 16 07:49:50 2014 +0000
Parent:
1:075e57eccf3a
Commit message:
learn the BusInOut Class to make a key-controlled program

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Feb 12 11:59:55 2013 +0000
+++ b/main.cpp	Thu Oct 16 07:49:50 2014 +0000
@@ -1,16 +1,33 @@
+/*************************************************
+*file name : switch point
+*creator:Jacob Shi
+*Time:2014/10/16
+*Description: uses to key to control the counter
+*************************************************/
 #include "mbed.h"
- 
-BusInOut pins(p5, p10, p7);
- 
-int main() {
-    while(1) {
-        pins.output();
-        pins = 0x3;
-        wait(1);
-        pins.input();
-        wait(1);
-        if(pins == 0x6) {
-            printf("Hello!\n");
+char data[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
+char i=0;
+BusInOut key(p5);
+BusInOut portnum(p21,p22,p23,p24,p25,p26,p27,p28);
+int main() 
+  {
+    key.input();
+    portnum.output();
+    while(1) 
+    {
+
+            portnum=0x00;
+           if(key==0)
+           {
+                wait_ms(10);
+                if(key==0)
+                {
+                        while(!key);
+                        portnum=data[i];
+                        (i++)%10;
+                }
+
+           }     
+
         }
-    }
-}
\ No newline at end of file
+  }
\ No newline at end of file