Ensar Muratović Josip Kvesić

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 broj(dp2, dp1, dp28, dp6, dp5, dp27, dp26);
00004 BusOut cifra(dp23, dp24, dp25);
00005 DigitalOut tacka(dp4);
00006 AnalogIn ain(dp9);
00007  
00008 int segmenti[10] = {0x01, 0x4f, 0x12, 0x06, 0x4c,0x24, 0x20, 0x0f, 0x00, 0x04};
00009  
00010 void display(float value)
00011 {
00012     int TCifre[3] = {(int)(value),(int)(value*10) % 10,(int)(value*100) % 10};
00013     for(int i = 1; i <= 4; i = i * 2)
00014     {
00015         broj = segmenti[ TCifre[i / 2] ];
00016         cifra = ~i;
00017         tacka = (i == 1) ? 0 : 1;
00018         wait_ms(1);
00019         cifra=7;
00020     }
00021  
00022 }
00023  
00024 int main()
00025 {   
00026     float niz[50];
00027     float suma=0;
00028     float vrijednost=0;
00029     while(1){
00030        
00031         for(int i(0);i<50;i++){
00032          niz[i]=ain*3.3;
00033         suma+=niz[i];}
00034         vrijednost=suma/50;
00035 
00036         display(vrijednost);
00037          
00038         
00039         suma=0;
00040         
00041         
00042         
00043         
00044         }
00045 }