Armin Klačar Josip Kvesić

Dependencies:   mbed

Committer:
tim007
Date:
Thu May 08 15:23:44 2014 +0000
Revision:
0:93a79d0fe805
LV8-PAI-Grupa6-Tim007

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tim007 0:93a79d0fe805 1 #include "mbed.h"
tim007 0:93a79d0fe805 2 Serial pc (USBTX, USBRX);
tim007 0:93a79d0fe805 3 BusIn columns(dp9,dp10,dp11,dp13);
tim007 0:93a79d0fe805 4 BusOut rows(dp2, dp1, dp28, dp6);
tim007 0:93a79d0fe805 5 Timer deb;
tim007 0:93a79d0fe805 6
tim007 0:93a79d0fe805 7 char button(){
tim007 0:93a79d0fe805 8 char character[16] = {'1','2','3','A','4','5','6','B','7','8','9','C','*','0','#','D'};
tim007 0:93a79d0fe805 9 for(int i = 0; i <= 3; i++)
tim007 0:93a79d0fe805 10 {
tim007 0:93a79d0fe805 11 rows = (1 << i);
tim007 0:93a79d0fe805 12 for(int j = 0; j <= 3; j++)
tim007 0:93a79d0fe805 13 if(columns == (1 << j)){
tim007 0:93a79d0fe805 14 if (deb.read_ms()<400) return NULL;
tim007 0:93a79d0fe805 15 deb.reset();
tim007 0:93a79d0fe805 16 return character[ i * 4 + j ];
tim007 0:93a79d0fe805 17 }
tim007 0:93a79d0fe805 18 }
tim007 0:93a79d0fe805 19 return NULL;
tim007 0:93a79d0fe805 20 }
tim007 0:93a79d0fe805 21 void display(){
tim007 0:93a79d0fe805 22 char c = button();
tim007 0:93a79d0fe805 23 if (c==NULL) return;
tim007 0:93a79d0fe805 24 if (c=='*') pc.putc ('\n');
tim007 0:93a79d0fe805 25 else pc.putc (c);
tim007 0:93a79d0fe805 26
tim007 0:93a79d0fe805 27 }
tim007 0:93a79d0fe805 28 int main() {
tim007 0:93a79d0fe805 29 rows=0;
tim007 0:93a79d0fe805 30 deb.start();
tim007 0:93a79d0fe805 31 while(1){display();}
tim007 0:93a79d0fe805 32 }