//conversor de bcd a 7 segmentos

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
cristiany
Date:
Sat Aug 19 21:50:37 2017 +0000
Parent:
0:da3425777443
Commit message:
ADC WITH LEDS

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
seg.cpp Show annotated file Show diff for this revision Revisions of this file
seg.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Aug 12 21:44:02 2017 +0000
+++ b/main.cpp	Sat Aug 19 21:50:37 2017 +0000
@@ -1,21 +1,39 @@
-//conversor de bcd a 7 segmentos
+//ADC Conversor with Leds' Ruler
 
 //Cristian Yomayuza
 //Anderson Murte
 //Arley Rueda
 
-#include "mbed.h"
 #include "seg.h"
-
-int number;
-int main() 
-{
-    cod yoma;
-    yoma.salida(D6,D7,D8,D9,D10,D11,D12);
+ 
+AnalogIn analog_value(A0);
+float Vvolt[13]={0,0.275,0.55,0.825,1.1,1.3,1.6,1.9,2.2,2.4,2.7,3,3.3};
+float Lectura;
+int Local;
+int main()
+ {
+    cod obj;
+    obj.salida(D2,D3,D4,D5,D6,D7,D8,D9,D10,D11,D12,D13);
     while(1) 
     {
-        number=yoma.enter(D2,D3,D4,D5);
-        yoma.bcd(number);
-        wait(0.5);    
+        Lectura=analog_value.read_u16()*0.00005;
+        
+        
+        for(int i=0;i<14;i++)
+        {
+            if(Lectura<=Vvolt[i])
+            {
+                Local=i;
+               break;
+            }
+            
+            
+        }
+         obj.leds(Local);
+                wait(0.9);
+        
+              
+        
+        
     }
 }
--- a/seg.cpp	Sat Aug 12 21:44:02 2017 +0000
+++ b/seg.cpp	Sat Aug 19 21:50:37 2017 +0000
@@ -1,19 +1,14 @@
 #include "seg.h"
 
-int arreglo[16]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x58,0x00,0x18,0x08,0x46,0x21,0x06,0x0e};
-int cod::enter(PinName a,PinName b,PinName c,PinName d)
+int arreglo[13]={0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF,0x1FF,0x3FF,0x7FF,0xFFF};
+
+void cod::salida(PinName a,PinName b,PinName c,PinName d,PinName e,PinName f,PinName g,PinName h, PinName i, PinName j, PinName k, PinName l)
 {
-    BusIn dip(a,b,c,d);
-    sw=dip.read();
-    return sw;   
-}
-void cod::salida(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;h_=h;i_=i;j_=j;k_=k;l_=l;
+   
+} 
+void cod::leds(int number)
 {
-    a_=a;b_=b;c_=c;d_=d;e_=e;f_=f;g_=g;
-    
-}  
-void cod::bcd(int number)
-{
-    BusOut display(a_,b_,c_,d_,e_,f_,g_);
+    BusOut display(a_,b_,c_,d_,e_,f_,g_,h_,i_,j_,k_,l_);
     display=arreglo[number];
 }
\ No newline at end of file
--- a/seg.h	Sat Aug 12 21:44:02 2017 +0000
+++ b/seg.h	Sat Aug 19 21:50:37 2017 +0000
@@ -1,16 +1,15 @@
 #ifndef seg_h
 #define seg_h
 #include "mbed.h"
-
 class cod
 {
     public:
-    int enter(PinName a,PinName b,PinName c,PinName d);
-    void salida(PinName a,PinName b,PinName c,PinName d,PinName e,PinName f,PinName g);
-    void bcd(int number);
-    private:
-    PinName a_;PinName b_;PinName c_;PinName d_;PinName e_;PinName f_;PinName g_;
-    int sw;
+    
+    void salida(PinName a,PinName b,PinName c,PinName d,PinName e,PinName f,PinName g,PinName h, PinName i, PinName j, PinName k, PinName l);
+    void leds(int number);
+     private:
+    PinName a_;PinName b_;PinName c_;PinName d_;PinName e_;PinName f_;PinName g_;PinName h_; PinName i_; PinName j_; PinName k_; PinName l_;
+    
 };
 
 #endif
\ No newline at end of file