parte de presión

Dependencies:   TextLCD mbed

Revision:
0:755152c45706
Child:
1:ebeb3d48c375
diff -r 000000000000 -r 755152c45706 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 14 16:09:26 2015 +0000
@@ -0,0 +1,79 @@
+#include "mbed.h"
+#include "TextLCD.h"
+#include "AnalogIn.h"
+
+TextLCD lcd(PTD3, PTA12, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD16x2);
+AnalogIn presionin(PTB2);
+float caspresion;
+int  BA=0,tipobanio=0,ev;
+Serial pc(USBTX, USBRX);
+
+int main()
+{
+   
+
+    while (true) {
+        caspresion = presionin.read() * 3.3;
+        lcd.cls();
+       
+
+        switch(tipobanio) {
+
+            case 0:
+                lcd.locate(0,0);
+                lcd.printf("Banio Rapido");
+                if (caspresion < 2.34 && BA == 0 ) {
+                    ev = 1;
+                    lcd.locate(0,1);
+                    lcd.printf("pres=%.2f EV= %d",caspresion,ev);
+                }
+                if ( caspresion >= 2.34 && BA == 0) {
+                    BA=1;
+                    ev = 0;
+                   lcd.locate(0,1);
+                    lcd.printf("pres=%.2f EV= %d",caspresion,ev);
+                }
+                if(caspresion == 0 && BA==1 ) 
+                    {
+                        BA = 0;
+                        lcd.locate(0,1);
+                        lcd.printf("pres=%.2f EV= %d",caspresion,ev);
+                }
+                if ( BA == 1 ) {
+                    
+                    lcd.locate(0,1);
+                    lcd.printf("pres=%.2f EV= %d",caspresion,ev);
+                }
+                break;
+            case 1:
+                lcd.locate(0,0);
+                lcd.printf("Banio Rapido");
+                  if (caspresion < 1.70 && BA == 0 ) {
+                    ev = 1;
+                   lcd.locate(0,1);
+                    lcd.printf("pres=%.2f EV= %d",caspresion,ev);
+                }
+                if ( caspresion >= 1.70) {
+                    BA=1;
+                    ev = 0;
+                    lcd.locate(0,1);
+                    lcd.printf("pres=%.2f EV= %d",caspresion,ev);
+                }
+                if( caspresion == 0 && BA==1 ) {
+                        BA = 0;
+                        lcd.locate(0,1);
+                        lcd.printf("pres=%.2f EV= %d",caspresion,ev);
+                }
+                 if (caspresion < 1.70 && BA == 1 ) {
+                    
+                    lcd.locate(0,1);
+                    lcd.printf("pres=%.2f EV= %d",caspresion,ev);
+                }
+              
+                break;
+            default:
+                break;
+        }
+wait(1);
+    }
+}