tim010 tim010
/
LV4-Grupa4-Tim010-Z3
Amra Dautbegović Luka Pejović
main.cpp
- Committer:
- tim010
- Date:
- 2014-03-24
- Revision:
- 1:c2b35dd17b66
- Parent:
- 0:6e4c4f02ef1b
File content as of revision 1:c2b35dd17b66:
#include "mbed.h" #include <cmath> DigitalOut cifre[3] = {dp23, dp24, dp25}; BusOut disp(dp4, dp2, dp1, dp28, dp6, dp5, dp27, dp26); //Novo za LV4 AnalogIn ulaz(dp9); int _7sd(char znak, bool tocka = false) { //za sljedeci raspored: a b c d e f g dp //a to su dp26 dp27 dp5 dp6 dp28 dp1 dp2 dp4 int t = !tocka; switch(znak) { case 'N': return 0xfe | t; case '0': return 0x02 | t; case '1': return 0x9e | t; case '2': return 0x24 | t; case '3': return 0x0c | t; case '4': return 0x98 | t; case '5': return 0x48 | t; case '6': return 0x40 | t; case '7': return 0x1a | t; case '8': return 0x00 | t; case '9': return 0x08 | t; case 'a': case 'A': return 0x10 | t; case 'b': case 'B': return 0xc0 | t; case 'c': case 'C': return 0x62 | t; case 'd': case 'D': return 0x84 | t; case 'e': case 'E': return 0x60 | t; case 'f': case 'F': return 0x70 | t; case '*': return 0x90 | t; case '#': return 0x6c | t; } } void ispisi(int broj){ if(broj < 0) broj = 0.0; int znakovi[3] = {(broj%1000)/100, (broj%100)/10, broj%10}; for(int i = 0; i < 3; i++){ cifre[i] = 0; disp = _7sd(znakovi[i] + '0', i==1); //tacku na prvom wait(0.0025); //ovo mijenjati da se ustima bolje svjetlo cifre[i] = 1; } } int main() { //char c, c1; int counter = 0; float pot, suma; float k = 1000*3.3; wait(0.05); float R0 = 1000, T0 = 298.15, B = 3400; pot = ulaz; while(1){ if(counter == 10){ pot = suma/50.f; counter = 0; suma = 0; } ispisi(1000./(log((pot/0.003)/R0)+B/T0)); suma += ulaz; counter++; } }