Zlatan Čilić Lejla Agić

Dependencies:   mbed

Revision:
0:4dbf5eb608c7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon May 12 07:34:19 2014 +0000
@@ -0,0 +1,68 @@
+#include "mbed.h"
+
+DigitalOut rows[4]={dp2,dp1,dp28,dp6};
+DigitalIn columns[4]={dp13,dp11,dp10,dp9};
+Serial pc(USBTX, USBRX);
+Ticker tiker;
+
+
+bool press(DigitalIn button)
+{
+    if(!button)
+        return false;
+    int counter=0;
+    for(int i=0;i<200;i++)
+        if(button) counter++;
+    if(counter>=120) return true;
+    return false;
+}
+
+
+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 ocitajIspisi()
+{
+    char c = giveChar();
+    if(c != 0)
+    {
+        if(c == '*') pc.putc('\n');
+        else pc.putc(c);
+    }
+}
+
+int main()
+{
+    tiker.attach(&ocitajIspisi, 0.2);
+    while(1)
+    {
+
+    }   
+}
\ No newline at end of file