Código para STM32 con núcleo F103, para la medición de un voltaje analógico por medio de un potenciómetro.

Dependencies:   mbed TextLCD

Files at this revision

API Documentation at this revision

Comitter:
lmrinconp
Date:
Sat Jun 08 14:05:31 2019 +0000
Commit message:
confirm

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Sat Jun 08 14:05:31 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jun 08 14:05:31 2019 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+#include "TextLCD.h"
+ 
+DigitalOut myled(PC_13);  //Activando el led de la tarjeta
+
+AnalogIn vi(PA_0);
+TextLCD lcd(PA_8, PA_9, PA_11, PA_12, PA_15, PB_3);// Declaración de los puertos
+
+int main()
+{
+    float v;
+    int j=0;
+    lcd.cls();
+    lcd.locate(0,0);
+    lcd.printf("     Tarea");     //Titulo del proyecto
+    lcd.locate(0,1);
+    lcd.printf("  Conversor AD"); //Titulo del proyecto
+    wait(8.0);
+    lcd.cls();
+    while(1) {
+        v = 3.3*vi.read_u16()/65535; //Normalización de la lectura del voltaje a una escala de [0-3.3]
+        myled=1;
+        wait(0.05);
+        myled=0;
+        lcd.locate(0,0);lcd.printf("VEscala= %d", vi.read_u16()); //Muestra de la lectruta Analogica entre [0-65535]
+        lcd.locate(0,1);
+        lcd.printf("VReal= %f ", v);  //Muestra del voltaje normalizado
+        j++;
+        wait(0.8);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jun 08 14:05:31 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file