Amela Spica Elma Kusundzija
Fork of lv3-grupa5-tim010-zadatak1 by
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 BusOut broj(dp2,dp1,dp28,dp6,dp5,dp27,dp26); 00004 DigitalOut dec_zarez(dp4); 00005 DigitalOut enable(dp14); 00006 DigitalOut redni_br_cifre[3]={dp23,dp24,dp25}; 00007 BusOut red(dp16,dp15,dp17,dp18); 00008 BusIn kolona(dp9,dp10,dp11,dp13); 00009 Timer timer; 00010 int niz_brojeva[10]={1,79,18,6,76,36,32,15,0,4}; 00011 int taster() 00012 { 00013 int taster1=0; 00014 red=1; 00015 if(kolona==1)taster1=1; 00016 else if(kolona==2)taster1=2; 00017 else if(kolona==4)taster1=3; 00018 00019 00020 00021 red=2; 00022 if(kolona==1)taster1=4; 00023 else if(kolona==2)taster1=5; 00024 else if(kolona==4)taster1=6; 00025 00026 00027 00028 red=4; 00029 if(kolona==1)taster1=7; 00030 else if(kolona==2)taster1=8; 00031 else if(kolona==4)taster1=9; 00032 else if(kolona==8)taster1=10; 00033 00034 red=8; 00035 00036 if(kolona==2)taster1=0; 00037 00038 00039 return taster1; 00040 } 00041 void funkcija(int x) 00042 { 00043 int i; 00044 if(x>999)return; 00045 if(x==10){redni_br_cifre[0]=0; broj=255;wait(0.001);} 00046 if(x/100!=0)i=3; 00047 else if(x/10!=0)i=2; 00048 else if(x!=0)i=1; 00049 else i=0; 00050 00051 if(i==3) 00052 { 00053 int prva_cifra=x/100; 00054 int druga_cifra=(x/10)%10; 00055 int treca_cifra=x%10; 00056 00057 broj=niz_brojeva[prva_cifra]; 00058 redni_br_cifre[0]=0; 00059 wait(0.001); 00060 redni_br_cifre[0]=1; 00061 00062 broj=niz_brojeva[druga_cifra]; 00063 redni_br_cifre[1]=0; 00064 wait(0.001); 00065 redni_br_cifre[1]=1; 00066 00067 broj=niz_brojeva[treca_cifra]; 00068 redni_br_cifre[2]=0; 00069 wait(0.001); 00070 redni_br_cifre[2]=1; 00071 00072 } 00073 else if(i==2) 00074 { 00075 int druga_cifra=x/10; 00076 int treca_cifra=x%10; 00077 00078 00079 broj=niz_brojeva[druga_cifra]; 00080 redni_br_cifre[1]=0; 00081 wait(0.001); 00082 redni_br_cifre[1]=1; 00083 00084 broj=niz_brojeva[treca_cifra]; 00085 redni_br_cifre[2]=0; 00086 wait(0.001); 00087 redni_br_cifre[2]=1; 00088 } 00089 else if(i==1) 00090 { 00091 int prva_cifra=x; 00092 00093 broj=niz_brojeva[prva_cifra]; 00094 redni_br_cifre[2]=0; 00095 wait(0.001); 00096 redni_br_cifre[2]=1; 00097 } 00098 else return; 00099 00100 } 00101 00102 int main() { 00103 enable=1; 00104 int trenutni_broj=0; 00105 bool i=false; 00106 while(1) 00107 { 00108 while(taster()==0) 00109 { 00110 if(trenutni_broj==10)trenutni_broj=0; 00111 if(i==false) 00112 { 00113 i=true; 00114 trenutni_broj=trenutni_broj*10; 00115 } 00116 funkcija(trenutni_broj); 00117 wait(0.001); 00118 } 00119 00120 i=false; 00121 while(taster()==1) 00122 { 00123 if(trenutni_broj==10)trenutni_broj=0; 00124 if(i==false) 00125 { 00126 i=true; 00127 trenutni_broj=trenutni_broj*10+1; 00128 } 00129 funkcija(trenutni_broj); 00130 wait(0.001); 00131 } 00132 00133 i=false; 00134 while(taster()==2) 00135 { 00136 if(trenutni_broj==10)trenutni_broj=0; 00137 if(i==false) 00138 { 00139 i=true; 00140 trenutni_broj=trenutni_broj*10+2; 00141 } 00142 funkcija(trenutni_broj); 00143 wait(0.001); 00144 } 00145 00146 i=false; 00147 while(taster()==3) 00148 { 00149 if(trenutni_broj==10)trenutni_broj=0; 00150 if(i==false) 00151 { 00152 i=true; 00153 trenutni_broj=trenutni_broj*10+3; 00154 } 00155 funkcija(trenutni_broj); 00156 wait(0.001); 00157 } 00158 00159 i=false; 00160 while(taster()==4) 00161 { 00162 if(trenutni_broj==10)trenutni_broj=0; 00163 if(i==false) 00164 { 00165 i=true; 00166 trenutni_broj=trenutni_broj*10+4; 00167 } 00168 funkcija(trenutni_broj); 00169 wait(0.001); 00170 } 00171 00172 i=false; 00173 while(taster()==5) 00174 { 00175 if(trenutni_broj==10)trenutni_broj=0; 00176 if(i==false) 00177 { 00178 i=true; 00179 trenutni_broj=trenutni_broj*10+5; 00180 } 00181 funkcija(trenutni_broj); 00182 wait(0.001); 00183 } 00184 00185 i=false; 00186 while(taster()==6) 00187 { 00188 if(trenutni_broj==10)trenutni_broj=0; 00189 if(i==false) 00190 { 00191 i=true; 00192 trenutni_broj=trenutni_broj*10+6; 00193 } 00194 funkcija(trenutni_broj); 00195 wait(0.001); 00196 } 00197 00198 i=false; 00199 while(taster()==7) 00200 { 00201 if(trenutni_broj==10)trenutni_broj=0; 00202 if(i==false) 00203 { 00204 i=true; 00205 trenutni_broj=trenutni_broj*10+7; 00206 } 00207 funkcija(trenutni_broj); 00208 wait(0.001); 00209 } 00210 00211 i=false; 00212 while(taster()==8) 00213 { 00214 if(trenutni_broj==10)trenutni_broj=0; 00215 if(i==false) 00216 { 00217 i=true; 00218 trenutni_broj=trenutni_broj*10+8; 00219 } 00220 funkcija(trenutni_broj); 00221 wait(0.001); 00222 } 00223 00224 i=false; 00225 while(taster()==9) 00226 { 00227 if(trenutni_broj==10)trenutni_broj=0; 00228 if(i==false) 00229 { 00230 i=true; 00231 trenutni_broj=trenutni_broj*10+9; 00232 } 00233 funkcija(trenutni_broj); 00234 wait(0.001); 00235 } 00236 00237 00238 i=false; 00239 while(taster()==10) 00240 { 00241 if(trenutni_broj==10)trenutni_broj=10; 00242 if(i==false) 00243 { 00244 i=true; 00245 trenutni_broj=0; 00246 } 00247 funkcija(trenutni_broj); 00248 wait(0.001); 00249 } 00250 00251 i=false; 00252 funkcija(trenutni_broj); 00253 } 00254 }
Generated on Fri Jul 29 2022 02:34:29 by
1.7.2
