parte de presión

Dependencies:   TextLCD mbed

main.cpp

Committer:
nahuel473cba
Date:
2015-12-14
Revision:
2:070d29e86c89
Parent:
1:ebeb3d48c375

File content as of revision 2:070d29e86c89:

#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.78 && BA == 0 ) {
                    ev = 1;
                    lcd.locate(0,1);
                    lcd.printf("pres=%.2f EV= %d",caspresion,ev);
                }
                if ( caspresion >= 2.30 && BA == 0) {
                    BA=1;
                    ev = 0;
                   lcd.locate(0,1);
                    lcd.printf("pres=%.2f EV= %d",caspresion,ev);
                }
                if(caspresion <= 1.5 && 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.9 && 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);
                }
                 if ( BA == 1 ) {
                    
                    lcd.locate(0,1);
                    lcd.printf("pres=%.2f EV= %d",caspresion,ev);
                }
              
                break;
            default:
                break;
        }
wait(1);
    }
}