parte de presión

Dependencies:   TextLCD mbed

main.cpp

Committer:
nahuel473cba
Date:
2015-12-14
Revision:
0:755152c45706
Child:
1:ebeb3d48c375

File content as of revision 0:755152c45706:

#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);
    }
}