tim003 tim003
/
Zadatak2-Tim3
Anes Luckin Selma Tucak
Diff: main.cpp
- Revision:
- 0:912ae55cc663
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Mar 20 19:19:52 2014 +0000 @@ -0,0 +1,105 @@ +#include "mbed.h" + +BusOut led(dp26, dp27, dp5, dp6, dp28, dp1, dp2); +BusOut dec(dp23, dp24, dp25); +BusOut tacka(dp4); +DigitalIn kolona[4] ={dp9,dp10,dp11,dp13}; +DigitalOut red[4] = {dp16,dp15,dp17,dp18}; + +int broj[10] = {0x40, 0x79, 0x24, 0x30, 0x19, 0x12, 0x02, 0x78, 0x00, 0x10}; + +int tast() +{ + for(int i=0;i<4;i++){ + red[i]=1; + for(int j=0;j<4;j++) + { + if(kolona[j]==1) + { + red[i]=0; + return 4*i+j; + } + } + red[i]=0; + } + return 20; +} + +int main() { + while(1) { + int b = tast(); + tacka = 1; + if(b==20) + { + dec=7; + continue; + } + if(b==0) + { + led = broj[1]; + dec=6; + wait_ms(2); + } + else if(b==1) + { + led = broj[2]; + dec=6; + wait_ms(2); + } + else if(b==2) + { + led = broj[3]; + dec=6; + wait_ms(2); + } + else if(b==4) + { + led = broj[4]; + dec=6; + wait_ms(2); + } + else if(b==5) + { + led = broj[5]; + dec=6; + wait_ms(2); + } + else if(b==6) + { + led = broj[6]; + dec=6; + wait_ms(2); + } + else if(b==8) + { + led = broj[7]; + dec=6; + wait_ms(2); + } + else if(b==9) + { + led = broj[8]; + dec=6; + wait_ms(2); + } + else if(b==10) + { + led = broj[9]; + dec=6; + wait_ms(2); + } + else if(b==11) + { + led = broj[0]; + dec=6; + wait_ms(2); + } + else if(b==13) + { + led = broj[0]; + dec=6; + wait_ms(2); + } + dec=7; + } +}