tim003 tim003
/
LV8_G6_Tim003_Zad2
Haris Spahic Ensar Muratovic
Revision 0:ab44456b9c0f, committed 2014-05-08
- Comitter:
- tim003
- Date:
- Thu May 08 15:30:58 2014 +0000
- Commit message:
- LV8-ZAD2-Grupa6-Tim003
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 ab44456b9c0f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 08 15:30:58 2014 +0000 @@ -0,0 +1,110 @@ +#include "mbed.h" + +DigitalIn Ulaz1(dp9); +DigitalIn Ulaz2(dp10); +DigitalIn Ulaz3(dp11); +DigitalIn Ulaz4(dp13); +DigitalOut Izlaz1(dp2); +DigitalOut Izlaz2(dp1); +DigitalOut Izlaz3(dp28); +DigitalOut Izlaz4(dp6); + +Ticker t1; +Timer debounce; +char ispis; + +Serial pc(USBTX, USBRX); + +char kojiJePritisnut() +{ + Izlaz1 = 1; + Izlaz2 = 0; + Izlaz3 = 0; + Izlaz4 = 0; + if(Ulaz1){ + return '1'; + } + if(Ulaz2){ + return '2'; + } + if(Ulaz3){ + return '3'; + } + if(Ulaz4){ + return 'A'; + } + + Izlaz1 = 0; + Izlaz2 = 1; + Izlaz3 = 0; + Izlaz4 = 0; + if(Ulaz1){ + return '4'; + } + if(Ulaz2){ + return '5'; + } + if(Ulaz3){ + return '6'; + } + if(Ulaz4){ + return 'B'; + } + + Izlaz1 = 0; + Izlaz2 = 0; + Izlaz3 = 1; + Izlaz4 = 0; + if(Ulaz1){ + return '7'; + } + if(Ulaz2){ + return '8'; + } + if(Ulaz3){ + return '9'; + } + if(Ulaz4){ + return 'C'; + } + + Izlaz1 = 0; + Izlaz2 = 0; + Izlaz3 = 0; + Izlaz4 = 1; + if(Ulaz1){ + return '\n'; //newline + } + if(Ulaz2){ + return '0'; + } + if(Ulaz3){ + return '#'; + } + if(Ulaz4){ + return 'D'; + } + + return 0; +} + +void ocitajTast() +{ + if(debounce.read_ms() < 150) + return; + + ispis = kojiJePritisnut(); + if(ispis == 0) + return; + + pc.putc(ispis); + + debounce.reset(); +} + +int main() { + debounce.start(); + while(1) + ocitajTast(); +} + \ No newline at end of file
diff -r 000000000000 -r ab44456b9c0f mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 08 15:30:58 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file