tim003 tim003
/
LV4_GRUPA2_TIM003_ZADATAK2
Granulo Eldar Beganovic Benjamin
Diff: main.cpp
- Revision:
- 0:74f4be59b17c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Mar 24 10:45:42 2014 +0000 @@ -0,0 +1,55 @@ +#include "mbed.h" + +#define WT 1 + +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 +DigitalOut tacka(dp4); +BusOut br_cifre_za_ispis(dp25, dp24, dp23);//dp23 dp24 dp25 +DigitalOut enable_display(dp14); +AnalogIn ulaz(dp9); + + + +//0-9,a-d,*,#////126, 48, 109, 121, 51, 91, 95, 114, 127, 123, 119, 31, 78, 61, 99, 55 +//0-9,a-d,*,#//////1, 79, 18, 6, 76, 36, 32, 13, 0, 4, 8, 96, 49, 66, 28, 72 + int cifre[]={ 1, 79, 18, 6, 76, 36, 32, 13, 0, 4}; + int br_cifre[]={3, 5, 6};//4, 2, 1 + +void displayReal(float broj) +{ + broj*=100; + int c_broj=broj; + + if(c_broj>100) c_broj=100; + //c_broj=100-c_broj; + int brojevi[3]={ c_broj/100, (c_broj/10)%10, c_broj%10 }; + for(int i(0); i<3; i++) + { + br_cifre_za_ispis=br_cifre[i]; + tacka=1; + cifra_za_ispis=cifre[ brojevi[i] ]; + wait_ms(WT); + br_cifre_za_ispis=7; + + } +} + +int main() +{ + enable_display=1; + cifra_za_ispis=127; + tacka=1; + + while(1) + { + float sum(0); + for(int i(0); i<100; i++) + { + sum+=ulaz*3.3; + wait_us(0.01); + + } + displayReal(1 - (sum/100.-0.38)); + } + return 0; +}