Sumejja Porca Edis Kunic

Dependencies:   mbed

Committer:
tim008
Date:
Thu May 08 17:22:03 2014 +0000
Revision:
0:c7046f93144e
LV08_Grupa7_Tim008_Z02;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tim008 0:c7046f93144e 1 #include "mbed.h"
tim008 0:c7046f93144e 2
tim008 0:c7046f93144e 3 Serial pc(USBTX, USBRX); // tx, rx
tim008 0:c7046f93144e 4
tim008 0:c7046f93144e 5 DigitalIn cols[4] = { dp9, dp10, dp11, dp13 }; //kolone
tim008 0:c7046f93144e 6 DigitalOut rows[4] = { dp2, dp1, dp28, dp6 }; //redovi
tim008 0:c7046f93144e 7
tim008 0:c7046f93144e 8
tim008 0:c7046f93144e 9 char getValue()
tim008 0:c7046f93144e 10 {
tim008 0:c7046f93144e 11 char c ('N');
tim008 0:c7046f93144e 12 for(int i = 0; i < 4; i++)
tim008 0:c7046f93144e 13 {
tim008 0:c7046f93144e 14 rows[i] = 0;
tim008 0:c7046f93144e 15 }
tim008 0:c7046f93144e 16
tim008 0:c7046f93144e 17 rows[0] = 1;
tim008 0:c7046f93144e 18
tim008 0:c7046f93144e 19 for(int i = 0; i < 4; i++)
tim008 0:c7046f93144e 20 {
tim008 0:c7046f93144e 21 if(cols[i] == 1)
tim008 0:c7046f93144e 22 switch(i)
tim008 0:c7046f93144e 23 {
tim008 0:c7046f93144e 24 case 0:
tim008 0:c7046f93144e 25 c = '1';
tim008 0:c7046f93144e 26 break;
tim008 0:c7046f93144e 27 case 1:
tim008 0:c7046f93144e 28 c = '2';
tim008 0:c7046f93144e 29 break;
tim008 0:c7046f93144e 30 case 2:
tim008 0:c7046f93144e 31 c = '3';
tim008 0:c7046f93144e 32 break;
tim008 0:c7046f93144e 33 case 3:
tim008 0:c7046f93144e 34 c = 'A';
tim008 0:c7046f93144e 35 break;
tim008 0:c7046f93144e 36 }
tim008 0:c7046f93144e 37 }
tim008 0:c7046f93144e 38 rows[0] = 0;
tim008 0:c7046f93144e 39 rows[1] = 1;
tim008 0:c7046f93144e 40
tim008 0:c7046f93144e 41 for(int i = 0; i < 4; i++)
tim008 0:c7046f93144e 42 {
tim008 0:c7046f93144e 43 if(cols[i] == 1)
tim008 0:c7046f93144e 44 switch(i)
tim008 0:c7046f93144e 45 {
tim008 0:c7046f93144e 46 case 0:
tim008 0:c7046f93144e 47 c = '4';
tim008 0:c7046f93144e 48 break;
tim008 0:c7046f93144e 49 case 1:
tim008 0:c7046f93144e 50 c = '5';
tim008 0:c7046f93144e 51 break;
tim008 0:c7046f93144e 52 case 2:
tim008 0:c7046f93144e 53 c = '6';
tim008 0:c7046f93144e 54 break;
tim008 0:c7046f93144e 55 case 3:
tim008 0:c7046f93144e 56 c = 'B';
tim008 0:c7046f93144e 57 break;
tim008 0:c7046f93144e 58 }
tim008 0:c7046f93144e 59 }
tim008 0:c7046f93144e 60
tim008 0:c7046f93144e 61
tim008 0:c7046f93144e 62 rows[1] = 0;
tim008 0:c7046f93144e 63 rows[2] = 1;
tim008 0:c7046f93144e 64
tim008 0:c7046f93144e 65 for(int i = 0; i < 4; i++)
tim008 0:c7046f93144e 66 {
tim008 0:c7046f93144e 67 if(cols[i] == 1)
tim008 0:c7046f93144e 68 switch(i)
tim008 0:c7046f93144e 69 {
tim008 0:c7046f93144e 70 case 0:
tim008 0:c7046f93144e 71 c = '7';
tim008 0:c7046f93144e 72 break;
tim008 0:c7046f93144e 73 case 1:
tim008 0:c7046f93144e 74 c = '8';
tim008 0:c7046f93144e 75 break;
tim008 0:c7046f93144e 76 case 2:
tim008 0:c7046f93144e 77 c = '9';
tim008 0:c7046f93144e 78 break;
tim008 0:c7046f93144e 79 case 3:
tim008 0:c7046f93144e 80 c = 'C';
tim008 0:c7046f93144e 81 break;
tim008 0:c7046f93144e 82 }
tim008 0:c7046f93144e 83 }
tim008 0:c7046f93144e 84
tim008 0:c7046f93144e 85
tim008 0:c7046f93144e 86 rows[2] = 0;
tim008 0:c7046f93144e 87 rows[3] = 1;
tim008 0:c7046f93144e 88
tim008 0:c7046f93144e 89 for(int i = 0; i < 4; i++)
tim008 0:c7046f93144e 90 {
tim008 0:c7046f93144e 91 if(cols[i] == 1)
tim008 0:c7046f93144e 92 switch(i)
tim008 0:c7046f93144e 93 {
tim008 0:c7046f93144e 94 case 0:
tim008 0:c7046f93144e 95 c = '*';
tim008 0:c7046f93144e 96 break;
tim008 0:c7046f93144e 97 case 1:
tim008 0:c7046f93144e 98 c = '0';
tim008 0:c7046f93144e 99 break;
tim008 0:c7046f93144e 100 case 2:
tim008 0:c7046f93144e 101 c = '#';
tim008 0:c7046f93144e 102 break;
tim008 0:c7046f93144e 103 case 3:
tim008 0:c7046f93144e 104 c = 'D';
tim008 0:c7046f93144e 105 break;
tim008 0:c7046f93144e 106 }
tim008 0:c7046f93144e 107 }
tim008 0:c7046f93144e 108
tim008 0:c7046f93144e 109 rows[3] = 0;
tim008 0:c7046f93144e 110 return c;
tim008 0:c7046f93144e 111 }
tim008 0:c7046f93144e 112
tim008 0:c7046f93144e 113
tim008 0:c7046f93144e 114
tim008 0:c7046f93144e 115 int main() {
tim008 0:c7046f93144e 116 char c = 'N';
tim008 0:c7046f93144e 117 char c1;
tim008 0:c7046f93144e 118
tim008 0:c7046f93144e 119 while(1) {
tim008 0:c7046f93144e 120 c1 = getValue();
tim008 0:c7046f93144e 121
tim008 0:c7046f93144e 122 if ( c1 != 'N' && c == 'N')
tim008 0:c7046f93144e 123 {
tim008 0:c7046f93144e 124 if (c1 == '*')
tim008 0:c7046f93144e 125 pc.putc ('\n');
tim008 0:c7046f93144e 126 else pc.putc(c1);
tim008 0:c7046f93144e 127
tim008 0:c7046f93144e 128 }
tim008 0:c7046f93144e 129 c = c1;
tim008 0:c7046f93144e 130 }
tim008 0:c7046f93144e 131 }
tim008 0:c7046f93144e 132