nahuel de la vega
/
presionRyN
parte de presión
main.cpp@0:755152c45706, 2015-12-14 (annotated)
- Committer:
- nahuel473cba
- Date:
- Mon Dec 14 16:09:26 2015 +0000
- Revision:
- 0:755152c45706
- Child:
- 1:ebeb3d48c375
PresionRyN
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 | 0:755152c45706 | 25 | if (caspresion < 2.34 && 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 | 0:755152c45706 | 30 | if ( caspresion >= 2.34 && 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 | 0:755152c45706 | 36 | if(caspresion == 0 && 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 | 0:755152c45706 | 62 | if( caspresion == 0 && 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 | 0:755152c45706 | 72 | |
nahuel473cba | 0:755152c45706 | 73 | break; |
nahuel473cba | 0:755152c45706 | 74 | default: |
nahuel473cba | 0:755152c45706 | 75 | break; |
nahuel473cba | 0:755152c45706 | 76 | } |
nahuel473cba | 0:755152c45706 | 77 | wait(1); |
nahuel473cba | 0:755152c45706 | 78 | } |
nahuel473cba | 0:755152c45706 | 79 | } |