código guía 2 sesión 1

Dependencies:   mbed

Fork of bdc_7seg by sergio burbano

Files at this revision

API Documentation at this revision

Comitter:
grupo3
Date:
Sat Aug 19 21:37:03 2017 +0000
Parent:
1:64569742f2ec
Commit message:
voltimetro

Changed in this revision

BCD_SEC.cpp Show annotated file Show diff for this revision Revisions of this file
BCD_SEC.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
diff -r 64569742f2ec -r 7dcd61e90e19 BCD_SEC.cpp
--- a/BCD_SEC.cpp	Sat Aug 12 21:03:54 2017 +0000
+++ b/BCD_SEC.cpp	Sat Aug 19 21:37:03 2017 +0000
@@ -1,18 +1,38 @@
 #include "BCD_SEC.h"
-int codhex[16]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x58,0x00,0x18,0x08,0x03,0x0b,0x23,0x4f,0x20};
+int codhex[10]= {0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x58,0x00,0x18};//,0x08,0x03,0x0b,0x23,0x4f,0x20
 int anodo::entrada(PinName a,PinName b, PinName c,PinName d)
 {
     BusIn dip(a,b,c,d);
     dipp=dip.read();
     return dip;
-    }
+}
 void anodo::visual(PinName seg_a,PinName seg_b, PinName seg_c,PinName seg_d,PinName seg_e,PinName seg_f, PinName seg_g)
 {
-    _a=seg_a;_b=seg_b;_c=seg_c;_d=seg_d;_e=seg_e;_f=seg_f;_g=seg_g;
-    }
+    _a=seg_a;
+    _b=seg_b;
+    _c=seg_c;
+    _d=seg_d;
+    _e=seg_e;
+    _f=seg_f;
+    _g=seg_g;
+}
 void anodo:: BDC(int number)
 {
     BusOut display (_g,_f,_e,_d,_c,_b,_a);
-display=codhex[number];
-    
-    }
\ No newline at end of file
+    display=codhex[number];
+
+}
+void anodo::dual(PinName uno, PinName two,int unidad,int decena,int tiempo)
+{DigitalOut habilitador1(uno);
+DigitalOut habilitardor2(two);
+    for(int u=0; u<tiempo; u++) {
+        habilitador1=1;
+        habilitardor2=0;
+        BDC(unidad);
+        wait(0.005);
+        habilitador1=0;
+        habilitardor2=1;
+        BDC(decena);
+        wait(0.005);
+    }
+}
\ No newline at end of file
diff -r 64569742f2ec -r 7dcd61e90e19 BCD_SEC.h
--- a/BCD_SEC.h	Sat Aug 12 21:03:54 2017 +0000
+++ b/BCD_SEC.h	Sat Aug 19 21:37:03 2017 +0000
@@ -4,12 +4,19 @@
 
 class anodo
 {
-    public: 
+public:
     int entrada(PinName dipa,PinName dipb, PinName dipc,PinName dipd );
     void visual(PinName seg_a,PinName seg_b, PinName seg_c,PinName seg_d,PinName seg_e,PinName seg_f, PinName seg_g);
     void BDC(int number);
-    private:
-    PinName _a;PinName _b;PinName _c;PinName _d;PinName _e;PinName _f;PinName _g;
+    void dual(PinName uno, PinName dos,int unidad,int decenas,int tiempo);
+private:
+    PinName _a;
+    PinName _b;
+    PinName _c;
+    PinName _d;
+    PinName _e;
+    PinName _f;
+    PinName _g;
     int dipp;
 };
 #endif
\ No newline at end of file
diff -r 64569742f2ec -r 7dcd61e90e19 main.cpp
--- a/main.cpp	Sat Aug 12 21:03:54 2017 +0000
+++ b/main.cpp	Sat Aug 19 21:37:03 2017 +0000
@@ -1,19 +1,25 @@
-//codigo correspondiente guia 2 primera sesion
+//codigo correspondiente guia 2 segunda sesion
 //sergio alejandro Burbano
 //daniel paez
 //wilmer alejandro pardo
 #include "BCD_SEC.h"
+//Serial pc(USBTX,USBRX);
+AnalogIn pot(A0);
+float voltaje;
+int unidad;
+int decena;
+int main()
 
-int numero;
-int main()          {
- anodo comd; 
- comd.visual(D6,D7,D8,D9,D10,D11,D12);
+{
+    anodo comd;
+    comd.visual(D6,D7,D8,D9,D10,D11,D12);//orden  prioridad display g,f,e,d,c,b,a
     while(1) {
- numero=comd.entrada(D2,D3,D4,D5);
-comd.BDC(numero);
-wait(0.3);
+        voltaje=pot.read_u16()*0.00005035;
+   //     pc.printf("la lectura:%0.2f\r",voltaje);
+        decena=voltaje;
+        unidad=((voltaje*10)-(decena*10));
+        comd.dual(D4,D5,unidad,decena,10);
+
     }
-    
-    
 }