Kiselica Aldin Muslija Adnan

Dependencies:   mbed

Revision:
0:feb8c38ed947
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon May 05 07:40:58 2014 +0000
@@ -0,0 +1,54 @@
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX);
+
+DigitalOut rows[4]={dp2,dp1,dp28,dp6};
+DigitalIn columns[4]={dp9,dp10,dp11,dp13};
+
+Ticker ticker;
+char giveChar()
+{
+    char value=0;
+    for(int i=0;i<4;i++)
+    {
+        rows[i]=1;
+        for(int j=0;j<4;j++)
+        {
+            if( i<3 && j<3 && columns[j] )
+                value= '1'+(i*3+j);
+                
+            if(j==3 && columns[j] )
+                value= 'a'+i;
+            if(i==3 && columns[j] )
+            {
+                if(j==0)
+                    value= '*';
+                if(j==1)
+                    value= '0';
+                if(j==2)
+                    value='#';
+            }
+        }
+        rows[i]=0;
+        if(value!=0)
+            break;
+    }            
+    return value;   
+}
+
+void displayChar()
+{
+    char c=giveChar();
+    if(c==0)
+    return;
+    if(c!='*')
+        pc.putc(c);
+    else if(c=='*')
+        pc.putc('\n');
+}
+int main() {
+    ticker.attach(displayChar,0.2);
+    while(1) {
+    
+    }
+}
\ No newline at end of file