nahuel de la vega
/
presionRyN
parte de presión
main.cpp@2:070d29e86c89, 2015-12-14 (annotated)
- Committer:
- nahuel473cba
- Date:
- Mon Dec 14 23:46:40 2015 +0000
- Revision:
- 2:070d29e86c89
- Parent:
- 1:ebeb3d48c375
presion valores bien
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nahuel473cba | 0:755152c45706 | 1 | #include "mbed.h" |
nahuel473cba | 0:755152c45706 | 2 | #include "TextLCD.h" |
nahuel473cba | 0:755152c45706 | 3 | #include "AnalogIn.h" |
nahuel473cba | 0:755152c45706 | 4 | |
nahuel473cba | 0:755152c45706 | 5 | TextLCD lcd(PTD3, PTA12, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD16x2); |
nahuel473cba | 0:755152c45706 | 6 | AnalogIn presionin(PTB2); |
nahuel473cba | 0:755152c45706 | 7 | float caspresion; |
nahuel473cba | 0:755152c45706 | 8 | int BA=0,tipobanio=0,ev; |
nahuel473cba | 0:755152c45706 | 9 | Serial pc(USBTX, USBRX); |
nahuel473cba | 0:755152c45706 | 10 | |
nahuel473cba | 0:755152c45706 | 11 | int main() |
nahuel473cba | 0:755152c45706 | 12 | { |
nahuel473cba | 0:755152c45706 | 13 | |
nahuel473cba | 0:755152c45706 | 14 | |
nahuel473cba | 0:755152c45706 | 15 | while (true) { |
nahuel473cba | 0:755152c45706 | 16 | caspresion = presionin.read() * 3.3; |
nahuel473cba | 0:755152c45706 | 17 | lcd.cls(); |
nahuel473cba | 0:755152c45706 | 18 | |
nahuel473cba | 0:755152c45706 | 19 | |
nahuel473cba | 0:755152c45706 | 20 | switch(tipobanio) { |
nahuel473cba | 0:755152c45706 | 21 | |
nahuel473cba | 0:755152c45706 | 22 | case 0: |
nahuel473cba | 0:755152c45706 | 23 | lcd.locate(0,0); |
nahuel473cba | 0:755152c45706 | 24 | lcd.printf("Banio Rapido"); |
nahuel473cba | 2:070d29e86c89 | 25 | if (caspresion < 2.78 && BA == 0 ) { |
nahuel473cba | 0:755152c45706 | 26 | ev = 1; |
nahuel473cba | 0:755152c45706 | 27 | lcd.locate(0,1); |
nahuel473cba | 0:755152c45706 | 28 | lcd.printf("pres=%.2f EV= %d",caspresion,ev); |
nahuel473cba | 0:755152c45706 | 29 | } |
nahuel473cba | 2:070d29e86c89 | 30 | if ( caspresion >= 2.30 && BA == 0) { |
nahuel473cba | 0:755152c45706 | 31 | BA=1; |
nahuel473cba | 0:755152c45706 | 32 | ev = 0; |
nahuel473cba | 0:755152c45706 | 33 | lcd.locate(0,1); |
nahuel473cba | 0:755152c45706 | 34 | lcd.printf("pres=%.2f EV= %d",caspresion,ev); |
nahuel473cba | 0:755152c45706 | 35 | } |
nahuel473cba | 2:070d29e86c89 | 36 | if(caspresion <= 1.5 && BA==1 ) |
nahuel473cba | 0:755152c45706 | 37 | { |
nahuel473cba | 0:755152c45706 | 38 | BA = 0; |
nahuel473cba | 0:755152c45706 | 39 | lcd.locate(0,1); |
nahuel473cba | 0:755152c45706 | 40 | lcd.printf("pres=%.2f EV= %d",caspresion,ev); |
nahuel473cba | 0:755152c45706 | 41 | } |
nahuel473cba | 0:755152c45706 | 42 | if ( BA == 1 ) { |
nahuel473cba | 0:755152c45706 | 43 | |
nahuel473cba | 0:755152c45706 | 44 | lcd.locate(0,1); |
nahuel473cba | 0:755152c45706 | 45 | lcd.printf("pres=%.2f EV= %d",caspresion,ev); |
nahuel473cba | 0:755152c45706 | 46 | } |
nahuel473cba | 0:755152c45706 | 47 | break; |
nahuel473cba | 0:755152c45706 | 48 | case 1: |
nahuel473cba | 0:755152c45706 | 49 | lcd.locate(0,0); |
nahuel473cba | 0:755152c45706 | 50 | lcd.printf("Banio Rapido"); |
nahuel473cba | 0:755152c45706 | 51 | if (caspresion < 1.70 && BA == 0 ) { |
nahuel473cba | 0:755152c45706 | 52 | ev = 1; |
nahuel473cba | 0:755152c45706 | 53 | lcd.locate(0,1); |
nahuel473cba | 0:755152c45706 | 54 | lcd.printf("pres=%.2f EV= %d",caspresion,ev); |
nahuel473cba | 0:755152c45706 | 55 | } |
nahuel473cba | 0:755152c45706 | 56 | if ( caspresion >= 1.70) { |
nahuel473cba | 0:755152c45706 | 57 | BA=1; |
nahuel473cba | 0:755152c45706 | 58 | ev = 0; |
nahuel473cba | 0:755152c45706 | 59 | lcd.locate(0,1); |
nahuel473cba | 0:755152c45706 | 60 | lcd.printf("pres=%.2f EV= %d",caspresion,ev); |
nahuel473cba | 0:755152c45706 | 61 | } |
nahuel473cba | 1:ebeb3d48c375 | 62 | if( caspresion <= 0.9 && BA==1 ) { |
nahuel473cba | 0:755152c45706 | 63 | BA = 0; |
nahuel473cba | 0:755152c45706 | 64 | lcd.locate(0,1); |
nahuel473cba | 0:755152c45706 | 65 | lcd.printf("pres=%.2f EV= %d",caspresion,ev); |
nahuel473cba | 0:755152c45706 | 66 | } |
nahuel473cba | 0:755152c45706 | 67 | if (caspresion < 1.70 && BA == 1 ) { |
nahuel473cba | 0:755152c45706 | 68 | |
nahuel473cba | 0:755152c45706 | 69 | lcd.locate(0,1); |
nahuel473cba | 0:755152c45706 | 70 | lcd.printf("pres=%.2f EV= %d",caspresion,ev); |
nahuel473cba | 0:755152c45706 | 71 | } |
nahuel473cba | 1:ebeb3d48c375 | 72 | if ( BA == 1 ) { |
nahuel473cba | 1:ebeb3d48c375 | 73 | |
nahuel473cba | 1:ebeb3d48c375 | 74 | lcd.locate(0,1); |
nahuel473cba | 1:ebeb3d48c375 | 75 | lcd.printf("pres=%.2f EV= %d",caspresion,ev); |
nahuel473cba | 1:ebeb3d48c375 | 76 | } |
nahuel473cba | 0:755152c45706 | 77 | |
nahuel473cba | 0:755152c45706 | 78 | break; |
nahuel473cba | 0:755152c45706 | 79 | default: |
nahuel473cba | 0:755152c45706 | 80 | break; |
nahuel473cba | 0:755152c45706 | 81 | } |
nahuel473cba | 0:755152c45706 | 82 | wait(1); |
nahuel473cba | 0:755152c45706 | 83 | } |
nahuel473cba | 0:755152c45706 | 84 | } |