tim008 tim008
/
LV08_Grupa7_Tim008_Z02
Sumejja Porca Edis Kunic
Revision 0:c7046f93144e, committed 2014-05-08
- Comitter:
- tim008
- Date:
- Thu May 08 17:22:03 2014 +0000
- Commit message:
- LV08_Grupa7_Tim008_Z02;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r c7046f93144e main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 08 17:22:03 2014 +0000 @@ -0,0 +1,132 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); // tx, rx + +DigitalIn cols[4] = { dp9, dp10, dp11, dp13 }; //kolone +DigitalOut rows[4] = { dp2, dp1, dp28, dp6 }; //redovi + + +char getValue() +{ + char c ('N'); + for(int i = 0; i < 4; i++) + { + rows[i] = 0; + } + + rows[0] = 1; + + for(int i = 0; i < 4; i++) + { + if(cols[i] == 1) + switch(i) + { + case 0: + c = '1'; + break; + case 1: + c = '2'; + break; + case 2: + c = '3'; + break; + case 3: + c = 'A'; + break; + } + } + rows[0] = 0; + rows[1] = 1; + + for(int i = 0; i < 4; i++) + { + if(cols[i] == 1) + switch(i) + { + case 0: + c = '4'; + break; + case 1: + c = '5'; + break; + case 2: + c = '6'; + break; + case 3: + c = 'B'; + break; + } + } + + + rows[1] = 0; + rows[2] = 1; + + for(int i = 0; i < 4; i++) + { + if(cols[i] == 1) + switch(i) + { + case 0: + c = '7'; + break; + case 1: + c = '8'; + break; + case 2: + c = '9'; + break; + case 3: + c = 'C'; + break; + } + } + + + rows[2] = 0; + rows[3] = 1; + + for(int i = 0; i < 4; i++) + { + if(cols[i] == 1) + switch(i) + { + case 0: + c = '*'; + break; + case 1: + c = '0'; + break; + case 2: + c = '#'; + break; + case 3: + c = 'D'; + break; + } + } + + rows[3] = 0; + return c; +} + + + +int main() { + char c = 'N'; + char c1; + + while(1) { + c1 = getValue(); + + if ( c1 != 'N' && c == 'N') + { + if (c1 == '*') + pc.putc ('\n'); + else pc.putc(c1); + + } + c = c1; + } +} + \ No newline at end of file
diff -r 000000000000 -r c7046f93144e mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 08 17:22:03 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file