REFRESCO DINAMICO CON DISPLAY 7 SEGMENTOS

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
mauricio1989
Date:
Sat Aug 19 21:54:24 2017 +0000
Parent:
0:1b88742b9c70
Commit message:
REFRESCO DINAMICO CON DISPLAYS 7 SEGMENTOS

Changed in this revision

katodo.cpp Show annotated file Show diff for this revision Revisions of this file
katodo.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 1b88742b9c70 -r 938f080c6be8 katodo.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/katodo.cpp	Sat Aug 19 21:54:24 2017 +0000
@@ -0,0 +1,39 @@
+#include "katodo.h"
+
+int kato[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67,0x77,0x7c,0x74,0x5c,0x30,0x5f};
+int katodo::entrada(PinName a,PinName b,PinName c,PinName d)
+
+{
+  BusIn dip(a,b,c,d);
+  dipp=dip.read();
+  return dipp; 
+}
+
+void katodo::visual(PinName a,PinName b,PinName c,PinName d,PinName e,PinName f,PinName g)
+{
+    _a=a;_b=b;_c=c;_d=d;_e=e;_f=f;_g=g;
+}
+
+void katodo::bcd(int numero)
+
+{
+        BusOut display(_g,_f,_e,_d,_c,_b,_a);
+        display=kato[numero];
+}
+void katodo::dual(PinName one,PinName two,int uni,int dec,int time)
+{
+    DigitalOut Eone(one);
+    DigitalOut Etwo(two);
+    for(int u=0;u<time;u++)
+    {
+        Eone=1;
+        Etwo=0;
+        bcd(uni);
+        wait(0.0005);
+        Eone=0;
+        Etwo=1;
+        bcd(dec);
+        wait(0.0005);
+        }
+}
+ 
\ No newline at end of file
diff -r 1b88742b9c70 -r 938f080c6be8 katodo.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/katodo.h	Sat Aug 19 21:54:24 2017 +0000
@@ -0,0 +1,23 @@
+#ifndef katodo_h //aquí creo la librería con el nombre katodo
+#define katodo_h //defino libreria
+#include "mbed.h"//Incluye las librerias generales de MBED
+
+class katodo   //Crea la clase para poder generar objetos
+
+{
+  public:   // aquí se crean los contructores que pueden ser usados por la persona.
+  int entrada (PinName a,PinName b,PinName c,PinName d); 
+  void visual(PinName a,PinName b,PinName c,PinName d,PinName e,PinName f,PinName g);
+  //El anterior constructor configura el display en el orden (a,b,c,d,e,f,g,dp) 
+  void bcd(int numero);
+  //El anterior constructor permite la visualización
+  void dual(PinName one,PinName two,int uni,int dec,int time);
+  private:
+  PinName _a;PinName _b;PinName _c;PinName _d;PinName _e;PinName _f;PinName _g;  
+  //las variables mencionadas anteriormente son creadas para evitar que el usuario las modifique
+  int dipp;
+  //las variables mencionadas anteriormente son creadas para evitar que el usuario las modifique  
+};
+
+
+#endif
\ No newline at end of file
diff -r 1b88742b9c70 -r 938f080c6be8 main.cpp
--- a/main.cpp	Mon Feb 27 00:27:54 2017 +0000
+++ b/main.cpp	Sat Aug 19 21:54:24 2017 +0000
@@ -1,30 +1,38 @@
-    #include "mbed.h"
+#include "mbed.h"
+#include "katodo.h"
+// RICARDO ROZO
+// ANDRES USMA
+// MAURICIO CADENA 
 Serial pc(USBTX,USBRX); 
-AnalogIn analog_value(PB_0);
-DigitalOut led1(PA_7);
-DigitalOut led2(PB_6);
-DigitalOut led3(PC_7);
-DigitalOut led4(PA_9);
-DigitalOut led5(PA_8);
-DigitalOut led6(PB_10);
-DigitalOut led7(PB_4);
-DigitalOut led8(PB_5);
-DigitalOut led9(PB_3);
-DigitalOut led10(PA_10);
-DigitalOut led11(PA_2);
-DigitalOut led12(PA_3);
-
+AnalogIn pot(A1);
+DigitalOut led1(D23);
+DigitalOut led2(D22);
+DigitalOut led3(D20);
+DigitalOut led4(D19);
+DigitalOut led5(D18);
+DigitalOut led6(D17);
+DigitalOut led7(D16);
+DigitalOut led8(D14);
+DigitalOut led9(D12);
+DigitalOut led10(D11);
+DigitalOut led11(D10);
+DigitalOut led12(D6); 
+float Volt; int uni;int dec;
  
 
 int main() {
-    float volt,vol_t,cont;
+ //katodo comd;
+ //comd.visual(D23,D22,D20,D19,D18,D17,D16);
          
     while(1) {
-        volt = analog_value.read_u16()*0.000050354; // Converts and read the analog input value (value from 0.0 to 1.0)
-        pc.printf("%f\n\r",volt);
+        Volt = pot.read_u16()*0.000050354; // Converts and read the analog input value (value from 0.0 to 1.0)
+        pc.printf("la lectura%0.2f\r",Volt);
+        //dec=Volt;
+        //uni=((Volt*10)-(dec*10));
+        //comd.dual(D2,D3,uni,dec,2000);
         wait(0.2);
         
-        if(volt<=0.275){ //1
+        if(Volt<=0.275){ //1
             led1=1;
             led2=0;
             led3=0;
@@ -38,21 +46,21 @@
             led11=0;
             led12=0;
             }
-        if(0.276<volt<=0.55){//2
-            led1=1;
-            led2=1;
-            led3=0;
-            led4=0;
-            led5=0;
-            led6=0;
-            led7=0;
-            led8=0;
-            led9=0;
-            led10=0;
-            led11=0;
-            led12=0;
-            }    
-      if(0.56<volt<=0.825){//3
+    if(0.276<Volt<=0.55){//2
+        led1=1;
+        led2=1;
+        led3=0;
+        led4=0;
+        led5=0;
+        led6=0;
+        led7=0;
+        led8=0;
+        led9=0;
+        led10=0;
+        led11=0;
+        led12=0;
+          }    
+  if(0.56<Volt<=0.825){//3
             led1=1;
             led2=1;
             led3=1;
@@ -66,7 +74,7 @@
             led11=0;
             led12=0;
             }   
-         if(0.826<volt<=1.1){//4
+         if(0.826<Volt<=1.1){//4
             led1=1;
             led2=1;
             led3=1;
@@ -80,7 +88,7 @@
             led11=0;
             led12=0;
             }   
-        if(1.11<volt<=1.375){//5
+        if(1.11<Volt<=1.375){//5
             led1=1;
             led2=1;
             led3=1;
@@ -94,7 +102,7 @@
             led11=0;
             led12=0;
             }   
-        if(1.376<volt<=1.65){//6
+        if(1.376<Volt<=1.65){//6
             led1=1;
             led2=1;
             led3=1;
@@ -108,7 +116,7 @@
             led11=0;
             led12=0;
             }
-    if(1.66<volt<=1.925){//7
+    if(1.66<Volt<=1.925){//7
             led1=1;
             led2=1;
             led3=1;
@@ -122,7 +130,7 @@
             led11=0;
             led12=0;
             }
-       if(1.926<volt<=2.2){//8
+       if(1.926<Volt<=2.2){//8
             led1=1;
             led2=1;
             led3=1;
@@ -136,7 +144,7 @@
             led11=0;
             led12=0;
             }
-      if(2.21<volt<=2.475){//9
+      if(2.21<Volt<=2.475){//9
             led1=1;
             led2=1;
             led3=1;
@@ -150,7 +158,7 @@
             led11=0;
             led12=0;
             }
-     if(2.476<volt<=2.75){//10
+     if(2.476<Volt<=2.75){//10
             led1=1;
             led2=1;
             led3=1;
@@ -164,7 +172,7 @@
             led11=0;
             led12=0;
             }
-        if(2.76<volt<=3.025){//11
+        if(2.76<Volt<=3.025){//11
             led1=1;
             led2=1;
             led3=1;
@@ -178,7 +186,7 @@
             led11=1;
             led12=0;
             }    
-       if(3.026<volt<=3.3){//12
+       if(3.026<Volt<=3.3){//12
             led1=1;
             led2=1;
             led3=1;
@@ -192,6 +200,5 @@
             led11=1;
             led12=1;
             }
-    }
+ }
 }
-