Ilvana Brankovic Emir Mujacic
Embed:
(wiki syntax)
Show/hide line numbers
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 float DajTemp(float napon) 00010 { 00011 float temp=napon/0.01; 00012 temp=temp*10; 00013 return temp; 00014 } 00015 void funkcija(float temperatura) 00016 { 00017 int brojevi[3]={(int)(temperatura)%10,(int)(temperatura/10)%10,(int)(temperatura/100)%10}; 00018 00019 cifre=3; 00020 ledice=niz[brojevi[2]]; 00021 wait_ms(1); 00022 cifre=7; 00023 00024 cifre=5; 00025 ledice=niz[brojevi[1]]; 00026 tacka=0; 00027 wait_ms(1); 00028 tacka=1; 00029 cifre=7; 00030 00031 cifre=6; 00032 ledice=niz[brojevi[0]]; 00033 wait_ms(1); 00034 cifre=7; 00035 } 00036 int main() { 00037 float nizf[100]; 00038 float srednja=0.0; 00039 float temperatura=0.0; 00040 while(1) { 00041 for(int i=0; i<100; i++) nizf[i]=naponcic; 00042 for(int i=0; i<100; i++) 00043 { srednja+=nizf[i]; funkcija(temperatura); } 00044 srednja=srednja/100; 00045 temperatura=DajTemp(srednja*3.30); 00046 funkcija(temperatura); 00047 } 00048 }
Generated on Thu Sep 1 2022 10:06:33 by
1.7.2