Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:db042111e9a9, committed 2014-03-24
- Comitter:
- tim010
- Date:
- Mon Mar 24 18:41:26 2014 +0000
- Commit message:
- LV4_Pai_Grupa004_Tim010; ;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Mar 24 18:41:26 2014 +0000 @@ -0,0 +1,88 @@ +#include "mbed.h" + +DigitalOut cifre[3] = {dp23, dp24, dp25}; +BusOut disp(dp4, dp2, dp1, dp28, dp6, dp5, dp27, dp26); +//Novo za LV4 +AnalogIn ulaz(dp9); +//end + +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', false); //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 x2(0.46/3.3), x1(2.2/3.3); + float k = (100/(x2 - x1)); + wait(0.05); + + pot = ulaz; + while(1){ + if(counter == 50){ + pot = suma/50.f; + counter = 0; + suma = 0; + } + ispisi((pot - x1) * k); + suma += ulaz; + counter++; + } + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Mar 24 18:41:26 2014 +0000 @@ -0,0 +1,1 @@ +http://world3.dev.mbed.org/users/mbed_official/code/mbed/builds/824293ae5e43 \ No newline at end of file