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     
00023     if(c_broj>100) c_broj=100;
00024     //c_broj=100-c_broj;
00025     int brojevi[3]={ c_broj/100, (c_broj/10)%10, c_broj%10 };
00026     for(int i(0); i<3; i++)
00027     {
00028         br_cifre_za_ispis=br_cifre[i];
00029         tacka=1;
00030         cifra_za_ispis=cifre[ brojevi[i] ];
00031         wait_ms(WT);
00032         br_cifre_za_ispis=7;
00033         
00034     }
00035 }
00036  
00037 int main()
00038 {
00039     enable_display=1;
00040     cifra_za_ispis=127;
00041     tacka=1;    
00042  
00043     while(1)
00044     {
00045         float sum(0);
00046         for(int i(0); i<100; i++)
00047         {
00048             sum+=ulaz*3.3;
00049             wait_us(0.01);
00050         
00051         }
00052         displayReal(1 - (sum/100.-0.38));
00053     }
00054     return 0;
00055 }