Programa que lee dos canales del adc y lo muestra sobre una pantalla lcd más un botón de cambio de pantalla para visualizar el valor entero del adc y su voltaje real

Dependencies:   mbed TextLCD

Files at this revision

API Documentation at this revision

Comitter:
Otakutronics
Date:
Wed Dec 19 00:40:10 2018 +0000
Commit message:
Lectura del modulo adc y se muestra sobre un lcd

Changed in this revision

TextLCD.lib 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 f2586ffe073a TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Wed Dec 19 00:40:10 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r f2586ffe073a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Dec 19 00:40:10 2018 +0000
@@ -0,0 +1,60 @@
+#include "mbed.h"
+#include "TextLCD.h"
+
+AnalogIn Canal1(A1); //PTB3
+AnalogIn Canal0(A0); //PTB2
+
+InterruptIn btn(PTA2);
+
+DigitalOut led(LED_RED,1);
+DigitalOut led2(LED_BLUE,1);
+
+TextLCD LCD(PTC2, PTC3, PTD0, PTD1, PTD2, PTD3); //rs, en, D4, D5, D6, D7
+
+bool sw = false;
+float AdcFlt;
+
+void ISR_Switch()
+{
+    sw = !sw;  
+    LCD.cls();
+    wait(0.25);     
+}
+
+int main()
+{
+    btn.mode(PullUp);
+    btn.rise(&ISR_Switch);
+    
+    wait(0.25);
+    LCD.cls();
+    wait(0.25);
+    
+    while (true) 
+    {
+        if (sw == 0)
+        {
+            LCD.locate(0,0);
+            LCD.printf("CH0 Valor: %5d",Canal0.read_u16());
+            LCD.locate(0,1);
+            LCD.printf("CH1 Valor: %5d",Canal1.read_u16());
+            led = 0;
+            wait(0.05);
+            led = 1;
+            wait(0.45);
+        }
+        else 
+        {
+            AdcFlt = Canal0.read_u16()*3.3/65536;
+            LCD.locate(0,0);
+            LCD.printf("CH0 Volts: %.3f",AdcFlt);
+            AdcFlt = Canal1.read_u16()*3.3/65536;
+            LCD.locate(0,1);
+            LCD.printf("CH1 Volts: %.3f",AdcFlt);
+            led2 = 0;
+            wait(0.05);
+            led2 = 1;
+            wait(0.45);    
+        }               
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f2586ffe073a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Dec 19 00:40:10 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae
\ No newline at end of file