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/10),(int)(value) % 10,(int)(value*10) % 10};
00013     for(int i = 1; i <= 4; i = i * 2)
00014     {
00015         broj = segmenti[ TCifre[i / 2] ];
00016         
00017         cifra = ~i;
00018         wait_ms(1);
00019         cifra=7;
00020     }
00021  
00022 }
00023  
00024 int main()
00025 {   
00026     float max=2.4;
00027     float min=0.8;
00028     float raz=max-min;
00029     float d=0;
00030     int i=0;
00031     while(1){
00032         
00033         
00034         if((ain*33)>=min && (ain*3.3)<=max)
00035         d=1-((ain*3.3)-min)/raz;
00036         else 
00037         d=0;
00038         display(d*100);
00039         i++;
00040         }
00041         
00042 }