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.
Revision 1:cc6233e787ea, committed 2020-02-15
- Comitter:
- rxavi
- Date:
- Sat Feb 15 19:19:36 2020 +0000
- Parent:
- 0:4193f27fd712
- Commit message:
- control de nivel
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 4193f27fd712 -r cc6233e787ea main.cpp
--- a/main.cpp Sat Feb 01 18:17:18 2020 +0000
+++ b/main.cpp Sat Feb 15 19:19:36 2020 +0000
@@ -1,12 +1,64 @@
-#include "mbed.h"
+#include "mbed.h" // llamado a la libreria mbed
+
+//Entradas digitales
+DigitalIn Pulsador(PA_0);
-DigitalOut myled(LED1);
+//Salidas digitales
+DigitalOut led_naranja(PD_13);
+DigitalOut led_verde(PD_12);
+DigitalOut led_rojo(PD_14);
+DigitalOut led_azul(PD_15);
+
+//Entradas analogicas
+ AnalogIn ain1(PC_1);
+
+//Salidas analogicas
+
+//Variables auxiliares
+
+//Comunicacion
+Serial device (PA_2,PA_3);
int main() {
+ device.baud(115200);
while(1) {
- myled = 1;
- wait(0.2);
- myled = 0;
- wait(0.2);
- }
-}
+ device.printf("Nivel en porcentaje: %0.1f%%\n", ain1.read()*100.0f);
+
+ if(ain1 < 0.1f) { //Condicionamiento para detectar nivel bajo bajo
+ led_rojo = 1; //Enciende indicador de nivel bajo bajo
+ device.printf("Alarma de nivel bajo bajo\r ");
+ }
+ else{
+ led_rojo = 0; //Apaga indicador de nivel bajo bajo
+ }
+
+ if(ain1 > 0.1f and ain1 < 0.3f) { //Condicionamiento para detectar nivel bajo
+ led_naranja = 1; //Enciende indicador de nivel bajo
+ }
+ else{
+ led_naranja = 0; //Apaga indicador de nivel bajo
+ }
+
+ if(ain1 > 0.3f and ain1 < 0.9f) { //Condicionamiento para detectar nivel normal
+ led_verde = 1; //Enciende indicador de nivel normal
+ }
+ else{
+ led_verde = 0; //Apaga indicador de nivel normal
+ }
+
+ if(ain1 > 0.9f) { //Condicionamiento para detectar nivel alto
+ led_azul = 1; //Enciende indicador de nivel alto
+ device.printf("Alarma de nivel alto\r ");
+ }
+ else{
+ led_azul = 0; //Apaga indicador de nivel alto
+ }
+
+ if(Pulsador == 1) { //Prueba de pulsador
+ device.printf("Pulsador presionado\n ");
+ }
+
+ wait(0.5f);
+ }
+}
+