Counter

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Eduvance
Date:
Tue May 27 07:28:31 2014 +0000
Parent:
0:776a127ae50b
Commit message:
A

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon May 19 10:25:26 2014 +0000
+++ b/main.cpp	Tue May 27 07:28:31 2014 +0000
@@ -1,12 +1,155 @@
 #include "mbed.h"
 
-DigitalOut myled(LED1);
+BusOut Disp1(p26,p25,p24,p23,p22,p21,p20); // ABCDEFGdp
+DigitalOut vdd(p19); 
+DigitalOut vddn(p18); 
+
+
+DigitalIn  row1(p14);                  //  row1 output
+DigitalIn  row2(p15);                  //  row2 output
+DigitalIn  row3(p16);                  //  row3 output
+DigitalIn  row4(p17); 
+                 
+DigitalOut   col1(p11);                  //  col2 input with 6k8 pullup to 3.3v 
+DigitalOut   col2(p12);                  //  col3 input with 6k8 pullup to 3.3v
+DigitalOut   col3(p13);                  //  col4 input with 6k8 pullup to 3.3v
+
+
+void setvdd() {
+    vddn=1;
+    vdd=0; 
+}
+
+int loop = 10;                          //  non zero value for the while loop
+
+void setcolhigh()   {
+    col1=1;                             //  set row1 low
+    col2=1;                             //  set row2 low
+    col3=1;
+                                //  set row3 low
+}
+void setcol1()      {
+    col1=0;                             //  set row1 low
+    col2=1;                             //  set row2 high
+    col3=1;
+                              //  set row3 high
+}
+void setcol2()      {
+    col1=1;                             //  set row1 high
+    col2=0;                             //  set row2 low
+    col3=1;
+                              //  set row3 high
+}
+void setcol3()      {
+    col1=1;                             //  set row1 high
+    col2=1;                             //  set row2 high
+    col3=0; 
+                             //  set row3 low
+}
+
+                             //  set row3 low
+
+
 
-int main() {
-    while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
-    }
+void key_1()   {                       
+        Disp1 = 0xF9;
+        
+}
+void key_2()   {
+        Disp1 = 0xA4;
+}
+void key_3()   {
+        Disp1 = 0xB0;
+}
+void key_4()   {
+        Disp1 = 0x99;
+}
+void key_5()   {
+        Disp1 = 0x92;
+}
+void key_6()   {
+        Disp1 = 0x82;
+}
+void key_7()   {
+        Disp1 = 0xF8;
+}
+void key_8()   {
+        Disp1 = 0x80;
+}
+void key_9()   {
+        Disp1 = 0x90;
+}
+void key_0()   {
+        Disp1 = 0xC0;
+}
+void key_le()   {
+       // lcd.locate(7,1);
+      //  lcd.printf("*");
+        Disp1 = 0x88;
+}
+void key_r()   {
+      // lcd.locate(7,1);
+      // lcd.printf("#");
+        Disp1 = 0xC6;
+}
+
+void key_nope()   {
+       Disp1 = 0x3F;
 }
+
+// keyscan function routine
+void keyscan() {
+    setcolhigh();
+    wait(0.2);
+    setcol1();
+    wait(0.2);
+    if (row1 == 0)
+        key_1();
+    if (row2 == 0)
+        key_4();
+    if (row3 == 0)
+        key_7();
+    if (row4 == 0)
+        key_le();
+    wait(0.1);
+    setcol2();
+    wait(0.2);
+    if (row1 == 0)
+        key_2();
+    if (row2 == 0)
+        key_5();
+    if (row3 == 0)
+        key_8();
+     if (row4 == 0)
+        key_0();
+        
+    wait(0.1);
+    setcol3();
+    wait(0.2);
+    if (row1 == 0)
+        key_3();
+    if (row2 == 0)
+        key_6();
+    if (row3 == 0)
+        key_9();
+    if (row4 == 0)
+        key_r();
+    
+   
+   // wait(0.1)    
+    //else 
+    //key_nope();   
+     
+   
+}
+
+//  main program routine
+int main()  {
+    
+    while (loop>0)  {
+        setvdd();
+    keyscan();                      //  run keyscan routine
+    wait(0.2);
+         
+       }
+}
\ No newline at end of file