conversor_ADC_leds

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
grupo3
Date:
Sat Aug 19 20:46:38 2017 +0000
Commit message:
conversor_ADC_leds

Changed in this revision

conver_AD.cpp Show annotated file Show diff for this revision Revisions of this file
conver_AD.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 e5c176dd2845 conver_AD.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/conver_AD.cpp	Sat Aug 19 20:46:38 2017 +0000
@@ -0,0 +1,93 @@
+#include "conver_AD.h"
+
+int codhex[13]= {0x00,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff,0x1ff,0x3ff,0x7ff,0xfff};
+
+void conversor::leds(PinName led1, PinName led2,PinName led3,PinName led4,PinName led5, PinName led6,PinName led7,PinName led8,PinName led9,PinName led10, PinName led11, PinName led12)
+{
+    _led1=led1;
+    _led2=led2;
+    _led3=led3;
+    _led4=led4;
+    _led5=led5;
+    _led6=led6;
+    _led7=led7;
+    _led8=led8;
+    _led9=led9;
+    _led10=led10;
+    _led11=led11;
+    _led12=led12;
+    }
+void conversor::regleta(float con)
+{
+    if(con<=0.275) {
+        BusOut display (_led1,_led2,_led3,_led4,_led5,_led6,_led7,_led8,_led9,_led10,_led11,_led12);
+        display=codhex[0] ;
+
+    }
+    if(con>0.275&&con<=0.275*2) {
+        BusOut display (_led1,_led2,_led3,_led4,_led5,_led6,_led7,_led8,_led9,_led10,_led11,_led12);
+        display=codhex[1] ;
+
+    }
+    if(con>0.275*2&&con<=0.275*3) {
+        BusOut display (_led1,_led2,_led3,_led4,_led5,_led6,_led7,_led8,_led9,_led10,_led11,_led12);
+        display=codhex[2] ;
+
+    }
+    if(con>0.275*3&&con<=0.275*4) {
+        BusOut display (_led1,_led2,_led3,_led4,_led5,_led6,_led7,_led8,_led9,_led10,_led11,_led12);
+        display=codhex[3] ;
+
+    }
+    if(con>0.275*4&&con<=0.275*5) {
+        BusOut display (_led1,_led2,_led3,_led4,_led5,_led6,_led7,_led8,_led9,_led10,_led11,_led12);
+        display=codhex[4] ;
+
+    }
+    if(con>0.275*5&&con<=0.275*6) {
+        BusOut display (_led1,_led2,_led3,_led4,_led5,_led6,_led7,_led8,_led9,_led10,_led11,_led12);
+        display=codhex[5] ;
+
+    }
+    if(con>0.275*6&&con<=0.275*7) {
+        BusOut display (_led1,_led2,_led3,_led4,_led5,_led6,_led7,_led8,_led9,_led10,_led11,_led12);
+        display=codhex[6] ;
+
+    }
+    if(con>0.275*7&&con<=0.275*8) {
+        BusOut display (_led1,_led2,_led3,_led4,_led5,_led6,_led7,_led8,_led9,_led10,_led11,_led12);
+        display=codhex[7] ;
+
+    }
+    if(con>0.275*8&&con<=0.275*9) {
+        BusOut display (_led1,_led2,_led3,_led4,_led5,_led6,_led7,_led8,_led9,_led10,_led11,_led12);
+        display=codhex[8] ;
+
+    }
+    if(con>0.275*9&&con<=0.275*10) {
+        BusOut display (_led1,_led2,_led3,_led4,_led5,_led6,_led7,_led8,_led9,_led10,_led11,_led12);
+        display=codhex[9] ;
+
+    }
+    if(con>0.275*10&&con<=0.275*11) {
+        BusOut display (_led1,_led2,_led3,_led4,_led5,_led6,_led7,_led8,_led9,_led10,_led11,_led12);
+        display=codhex[10] ;
+
+    } if(con>0.275*11&&con<=0.275*11.5) {
+        BusOut display (_led1,_led2,_led3,_led4,_led5,_led6,_led7,_led8,_led9,_led10,_led11,_led12);
+        display=codhex[11] ;
+
+    }
+    if(con>0.275*11.5) {
+        BusOut display (_led1,_led2,_led3,_led4,_led5,_led6,_led7,_led8,_led9,_led10,_led11,_led12);
+        display=codhex[12];
+
+    }
+ 
+    
+
+}
+
+
+
+
diff -r 000000000000 -r e5c176dd2845 conver_AD.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/conver_AD.h	Sat Aug 19 20:46:38 2017 +0000
@@ -0,0 +1,27 @@
+#ifndef conver_AD_h
+#define conver_AD_h
+#include "mbed.h"
+class conversor
+{
+public:
+    
+    void leds(PinName led1, PinName led2,PinName led3,PinName led4,PinName led5, PinName led6,PinName led7,PinName led8,PinName led9,PinName led10, PinName led11, PinName led12);
+    void regleta(float con);
+private:
+    PinName _led1;
+    PinName _led2;
+    PinName _led3;
+    PinName _led4;
+    PinName _led5;
+    PinName _led6;
+    PinName _led7;
+    PinName _led8;
+    PinName _led9;
+    PinName _led10;
+    PinName _led11;
+     PinName _led12;
+    int pote;
+
+};
+
+#endif
diff -r 000000000000 -r e5c176dd2845 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 19 20:46:38 2017 +0000
@@ -0,0 +1,22 @@
+//codigo correspondiente guia 2 primera sesion
+//sergio alejandro Burbano
+//daniel paez
+//wilmer alejandro pardo
+#include "conver_AD.h"
+AnalogIn lectura(A0);
+float regreso;
+Serial pc(USBTX,USBRX);
+int main()
+{
+
+
+    conversor salida;
+    salida.leds(D2,D3,D4,D5,D6,D7,D8,D9,D10,D11,D12,D13);
+    while(1) {
+    float con = lectura.read_u16()*0.000050354;
+         pc.printf("codigo:%f\n\r",con);
+          salida.regleta(con);
+            }
+
+
+}
\ No newline at end of file
diff -r 000000000000 -r e5c176dd2845 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Aug 19 20:46:38 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/fd96258d940d
\ No newline at end of file