Voltimetro digital 0 - 3,3v

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Digitalesavanzados
Date:
Sat Aug 20 19:15:25 2016 +0000
Commit message:
Voltimetro digital

Changed in this revision

Volti.cpp Show annotated file Show diff for this revision Revisions of this file
Volti.h Show annotated file Show diff for this revision Revisions of this file
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
diff -r 000000000000 -r d994dd919d32 Volti.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Volti.cpp	Sat Aug 20 19:15:25 2016 +0000
@@ -0,0 +1,62 @@
+#include "Volti.h"
+
+int x,y,z, unim=0, deco[10]= {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67};
+double x1,x2,ent;
+
+void voltime::configout(PinName a,PinName b,PinName c,PinName d,PinName e,PinName f,PinName g, PinName p, PinName kuni, PinName kdec,PinName kcen,PinName kunim)
+{
+
+    _a=a;
+    _b=b;
+    _c=c;
+    _d=d;
+    _e=e;
+    _f=f;
+    _g=g;
+    _p=p;
+    _kuni=kuni;
+    _kdec=kdec;
+    _kcen=kcen;
+    _kunim=kunim;
+
+}
+
+void voltime::vol(double ent)
+{
+
+    BusOut disp(_a,_b,_c,_d,_e,_f,_g);
+    DigitalOut p=_p;
+    DigitalOut kuni=_kuni;
+    DigitalOut kdec=_kdec;
+    DigitalOut kcen=_kcen;
+    DigitalOut kunim=_kunim;
+    ent = ent * 0.000050354;
+    x = ent;
+    x1 = ent - x;
+    x2 = x1 * 100;
+    y = x2 / 10;
+    z = x2 - (y*10);
+
+    disp=deco[x];
+    kcen=1;
+    p=1;
+    wait(0.007);
+    kcen=0;
+    p=0;
+
+    disp=deco[y];
+    kdec=1;
+    wait(0.007);
+    kdec=0;
+
+    disp=deco[z];
+    kuni=1;
+    wait(0.007);
+    kuni=0;
+
+    disp=deco[unim];
+    kunim=1;
+    wait(0.007);
+    kunim=0;
+
+}
\ No newline at end of file
diff -r 000000000000 -r d994dd919d32 Volti.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Volti.h	Sat Aug 20 19:15:25 2016 +0000
@@ -0,0 +1,29 @@
+#ifndef Volti
+#define Volti_h
+#include "mbed.h"
+
+class voltime
+{
+
+public:
+
+    void configout(PinName a,PinName b,PinName c,PinName d,PinName e,PinName f,PinName g, PinName p,PinName kuni, PinName kdec,PinName kcen,PinName kunim);
+    void vol(double ent);
+
+private:
+
+    PinName _a;
+    PinName _b;
+    PinName _c;
+    PinName _d;
+    PinName _e;
+    PinName _f;
+    PinName _g;
+    PinName _p;
+    PinName _kuni;
+    PinName _kdec;
+    PinName _kcen;
+    PinName _kunim;
+};
+
+#endif
\ No newline at end of file
diff -r 000000000000 -r d994dd919d32 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 20 19:15:25 2016 +0000
@@ -0,0 +1,18 @@
+#include "Volti.h"
+
+AnalogIn lec(A0);
+
+int main()
+{
+    double meas;
+    voltime lab2;
+    lab2.configout(D2,D3,D4,D5,D6,D7,D8,D9,D10,D11,D12,D13);
+
+    while(1) {
+
+        meas = lec.read_u16();
+        lab2.vol(meas);
+    }
+
+}
+
diff -r 000000000000 -r d994dd919d32 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Aug 20 19:15:25 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/2241e3a39974
\ No newline at end of file