Omerović Mirza Kurtović Ilma

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 cifra (dp26, dp27, dp5, dp6, dp28, dp1, dp2);
00004 DigitalOut zarez (dp4);
00005 BusOut izborCifre (dp23, dp24, dp25);
00006 AnalogIn ulaz(dp9);
00007 int brojevi[10]={0x40, 0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};
00008 /*int chars[6]={0x08,0x60,0x31,0x42,0x30,0x38};*/
00009 
00010 void pokaziCifru(int ulaz)
00011 {
00012     if (ulaz>=0 && ulaz<=9)
00013         cifra=brojevi[ulaz];
00014     else
00015         cifra=0x7f;
00016 }
00017 
00018 void ispisiVrijednost(float vrijednost)
00019 {
00020     int treca=(vrijednost-int(vrijednost))*10;
00021     int druga=int((vrijednost-int(vrijednost))*100)%10;
00022     int prva=int(vrijednost);
00023     izborCifre=6;
00024     pokaziCifru(prva);
00025     zarez=0;
00026     wait_ms(1);
00027     izborCifre=7;
00028     pokaziCifru(druga);
00029     izborCifre=5;
00030     wait_ms(1);
00031     izborCifre=7;
00032     pokaziCifru(treca);
00033     izborCifre=3;
00034     wait_ms(1);
00035     izborCifre=0;
00036 }
00037 int main() {
00038     int i=0;
00039     float ain=3.3;
00040     while(1) {
00041         if(i%100==0)
00042         ain=ulaz*3.3;
00043         ispisiVrijednost(ain);
00044         i++;
00045     }
00046 }