Anes Luckin Selma Tucak

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 BusOut led(dp26, dp27, dp5, dp6, dp28, dp1, dp2);
00004 BusOut dec(dp23, dp24, dp25);
00005 BusOut tacka(dp4);
00006 DigitalIn kolona[4] ={dp9,dp10,dp11,dp13};
00007 DigitalOut red[4] = {dp16,dp15,dp17,dp18};
00008 
00009 int broj[10] = {0x40, 0x79, 0x24, 0x30, 0x19, 0x12, 0x02, 0x78, 0x00, 0x10};
00010 
00011 int tast()
00012 {
00013     for(int i=0;i<4;i++){
00014     red[i]=1;
00015     for(int j=0;j<4;j++)
00016     {
00017         if(kolona[j]==1)
00018         {
00019             red[i]=0;
00020             return 4*i+j;
00021         }   
00022     }
00023     red[i]=0;
00024     }
00025         return 20;
00026 }
00027 
00028 int main() {
00029     while(1) {
00030        int b = tast();
00031        tacka = 1;
00032     if(b==20)
00033        {
00034         dec=7;
00035         continue;
00036         }
00037         if(b==0)
00038         {
00039         led = broj[1];
00040         dec=6; 
00041         wait_ms(2);
00042         }
00043                else if(b==1)
00044         {
00045         led = broj[2];
00046         dec=6; 
00047         wait_ms(2);
00048         }
00049                else if(b==2)
00050         {
00051         led = broj[3];
00052         dec=6; 
00053         wait_ms(2);
00054         }
00055                else if(b==4)
00056         {
00057         led = broj[4];
00058         dec=6; 
00059         wait_ms(2);
00060         }
00061                else if(b==5)
00062         {
00063         led = broj[5];
00064         dec=6; 
00065         wait_ms(2);
00066         }
00067                else if(b==6)
00068         {
00069         led = broj[6];
00070         dec=6; 
00071         wait_ms(2);
00072         }
00073                else if(b==8)
00074         {
00075         led = broj[7];
00076         dec=6; 
00077         wait_ms(2);
00078         }
00079                else if(b==9)
00080         {
00081         led = broj[8];
00082         dec=6; 
00083         wait_ms(2);
00084         }
00085                else if(b==10)
00086         {
00087         led = broj[9];
00088         dec=6; 
00089         wait_ms(2);
00090         }
00091                        else if(b==11)
00092         {
00093         led = broj[0];
00094         dec=6; 
00095         wait_ms(2);
00096         }
00097                        else if(b==13)
00098         {
00099         led = broj[0];
00100         dec=6; 
00101         wait_ms(2);
00102         }
00103         dec=7;
00104     }
00105 }