Granulo Eldar Beganovic Benjamin

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 #define WT 1
00004  
00005 BusOut cifra_za_ispis(dp2, dp1, dp28, dp6, dp5, dp27, dp26);//dp2, dp1, dp28, dp6, dp5, dp27, dp26   dp26, dp27, dp5, dp6, dp28, dp1, dp2
00006 DigitalOut tacka(dp4);
00007 BusOut br_cifre_za_ispis(dp25, dp24, dp23);//dp23 dp24 dp25
00008 DigitalOut enable_display(dp14);
00009 AnalogIn ulaz(dp9);
00010 
00011 
00012     
00013 //0-9,a-d,*,#////126, 48, 109, 121, 51, 91, 95, 114, 127, 123, 119, 31, 78, 61, 99, 55
00014 //0-9,a-d,*,#//////1, 79,  18,   6, 76, 36, 32,  13,   0,   4,   8, 96, 49, 66, 28, 72
00015     int cifre[]={  1, 79,  18,   6, 76, 36, 32,  13,   0,   4};
00016     int br_cifre[]={3, 5, 6};//4, 2, 1
00017 
00018 void displayReal(float broj)
00019 {
00020     broj*=100;
00021     int c_broj=broj;
00022     int brojevi[3]={ c_broj/100, (c_broj/10)%10, c_broj%10 };
00023     for(int i(0); i<3; i++)
00024     {
00025         br_cifre_za_ispis=br_cifre[i];
00026         
00027         if(i==0) tacka=0;
00028         cifra_za_ispis=cifre[ brojevi[i] ];
00029         wait_ms(WT);
00030         tacka=1;
00031         br_cifre_za_ispis=7;
00032         
00033     }
00034 }
00035  
00036 int main()
00037 {
00038     enable_display=1;
00039     cifra_za_ispis=127;
00040     tacka=1;    
00041  
00042     while(1)
00043     {
00044         float sum(0);
00045         for(int i(0); i<100; i++)
00046         {
00047             sum+=ulaz*3.3;
00048             wait_us(0.01);
00049         
00050         }
00051         displayReal(sum/100.);
00052     }
00053     return 0;
00054 }