Zlatan Čilić Lejla Agić

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 DigitalOut rows[4]={dp2,dp1,dp28,dp6};
00004 DigitalIn columns[4]={dp13,dp11,dp10,dp9};
00005 Serial pc(USBTX, USBRX);
00006 Ticker tiker;
00007 
00008 
00009 bool press(DigitalIn button)
00010 {
00011     if(!button)
00012         return false;
00013     int counter=0;
00014     for(int i=0;i<200;i++)
00015         if(button) counter++;
00016     if(counter>=120) return true;
00017     return false;
00018 }
00019 
00020 
00021 char giveChar()
00022 {
00023     char value=0;
00024     for(int i=0;i<4;i++)
00025     {
00026         rows[i]=1;
00027         for(int j=0;j<4;j++)
00028         {
00029             if( i<3 && j<3 && columns[j] )
00030                 value= '1'+(i*3+j);
00031                 
00032             if(j==3 && columns[j] )
00033                 value= 'a'+i;
00034             if(i==3 && columns[j] )
00035             {
00036                 if(j==0)
00037                     value= '*';
00038                 if(j==1)
00039                     value= '0';
00040                 if(j==2)
00041                     value='#';
00042             }
00043         }
00044         rows[i]=0;
00045         if(value!=0)
00046             break;
00047     }            
00048     return value; 
00049 }
00050 
00051 void ocitajIspisi()
00052 {
00053     char c = giveChar();
00054     if(c != 0)
00055     {
00056         if(c == '*') pc.putc('\n');
00057         else pc.putc(c);
00058     }
00059 }
00060 
00061 int main()
00062 {
00063     tiker.attach(&ocitajIspisi, 0.2);
00064     while(1)
00065     {
00066 
00067     }   
00068 }