Ilvana Brankovic Emir Mujacic

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 ledice(dp2,dp1,dp28,dp6,dp5,dp27,dp26);
00004 BusOut cifre(dp25,dp24,dp23);
00005 int niz[10]={0x01,0x4F,0x12,0x06,0x4C,0x24,0x20,0x0f,0x00,0x04};
00006 AnalogIn naponcic(dp9);
00007 DigitalOut tacka(dp4);
00008 
00009 void funkcija(float napon)
00010 {
00011     int brojevi[3]= {(int)(napon)%10,(int)(napon*10)%10,(int)(napon*100)%10};
00012     
00013     cifre=3;
00014     ledice=niz[brojevi[0]];
00015     tacka=0;
00016     wait_ms(2);
00017     tacka=1;
00018     cifre=7;
00019     
00020     cifre=5;
00021     ledice=niz[brojevi[1]];
00022     wait_ms(2);
00023     cifre=7;
00024     
00025     cifre=6;
00026     ledice=niz[brojevi[2]];
00027     wait_ms(2);
00028     cifre=7;
00029 }
00030 int main() {
00031     float nizf[100];
00032     float srednja=0.0;
00033     while(1) {
00034        for(int i=0; i<100; i++) nizf[i]=naponcic;
00035        for(int i=0; i<100; i++) srednja+=nizf[i];
00036        srednja=srednja/100;
00037        funkcija(srednja*3.3);
00038        srednja=0;
00039     }
00040 }