Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:3870563dc975
- Child:
- 1:434f82fb0641
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Jan 17 23:48:12 2019 +0000
@@ -0,0 +1,89 @@
+#include "mbed.h"
+
+AnalogIn sensor(PC_1); // Sensor 1
+
+DigitalOut led1(PD_12); // Led Verde
+DigitalOut led2(PD_13); // Led Naranja
+DigitalOut led3(PD_14); // Led Rojo
+
+Serial device(PA_2,PA_3); //Puerto serial
+
+int i, j, muestra, mediciones, tiempo;
+float T, lectura, acum, Tacum, promedio;
+
+int main()
+{
+ device.baud(19200); // Velocidad de Puerto Serial
+
+ device.printf ("Ingrese # de muestras: ");
+ device.scanf ("%d[^\n]",&muestra);
+ device.printf ("\n");
+ device.printf("%i \n", muestra);
+
+ device.printf ("Ingrese # de mediciones: ");
+ device.scanf ("%d[^\n]",&mediciones);
+ device.printf ("\n");
+ device.printf("%i \n", mediciones);
+
+ device.printf ("Ingrese Tiempo entre muestras: ");
+ device.scanf ("%d[^\n]",&tiempo);
+ device.printf ("\n");
+ device.printf("%i \n", tiempo);
+ device.printf("\n");
+
+ i = 1;
+ while(i < muestra + 1) // Presentacion de Muestras
+ {
+ device.printf("Muestra # %i \n", i);
+
+ j = 0;
+ acum = 0;
+ promedio = 0;
+
+ while (j < mediciones) // Presentacion de Mediciones
+ {
+ device.printf("Sensor : (%f)\n", sensor.read());
+
+ if (sensor.read() >= 0 && sensor.read() < 0.3)
+ {
+ T = (100.500001*sensor.read()) + 10; // Calculo Temperatura (0V = 10° y 1V = 40°)
+ led1 = 1;
+ }
+ else
+ led1 = 0;
+
+ if (sensor.read() >= 0.33 && sensor.read() < 0.6)
+ {
+ T = (145.166767*sensor.read()) - 6.66672735; // Calculo Temperatura (1.1V = 41° y 2V = 80°)
+ led2 = 1;
+ }
+ else
+ led2 = 0;
+
+ if (sensor.read() >= 0.64 && sensor.read() <= 1)
+ {
+ T = (211.719999*sensor.read()) - 51.719999; // Calculo Temperatura 3 (2.1V = 81° y 3.3V = 81°)
+ led3 = 1;
+ }
+ else
+ led3 = 0;
+
+ device.printf("Temperatura: (%4.2f)\n", T);
+ lectura = sensor.read();
+ acum = acum + lectura;
+ Tacum = Tacum + T;
+
+ wait(tiempo); // Espera de n seg por Mediciom
+ j++;
+ }
+
+ promedio = acum / j;
+ device.printf("\n");
+ device.printf("Promedio de mediciones: (%f)\n", promedio);
+ T = Tacum / j;
+ device.printf("Promedio de Temperatura: (%4.2f)\n", T);
+ device.printf("\n");
+
+ i++;
+ }
+}
\ No newline at end of file