electro
Dependencies: mbed QEI mbed-os KeypadLib TextLCD
electrocoagulador_final.cpp@1:48c8726d6824, 2019-03-01 (annotated)
- Committer:
- afsaavedram
- Date:
- Fri Mar 01 22:43:46 2019 +0000
- Revision:
- 1:48c8726d6824
- Parent:
- 0:6cde030caebb
- Child:
- 2:4b27d3d7341a
version1.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
afsaavedram | 0:6cde030caebb | 1 | #include "mbed.h" |
afsaavedram | 0:6cde030caebb | 2 | #include "keypad.h" |
afsaavedram | 0:6cde030caebb | 3 | #include "TextLCD.h" |
afsaavedram | 0:6cde030caebb | 4 | #include "stdlib.h" |
afsaavedram | 0:6cde030caebb | 5 | |
afsaavedram | 0:6cde030caebb | 6 | /*******************ELECTROVALVULAS********************/ |
afsaavedram | 0:6cde030caebb | 7 | |
afsaavedram | 0:6cde030caebb | 8 | DigitalOut E_1(D8); //Control de electrovalvula 1 |
afsaavedram | 0:6cde030caebb | 9 | DigitalOut E_2(D9); //Control de electrovalvula 2 |
afsaavedram | 0:6cde030caebb | 10 | DigitalOut E_3(D10); //Control de electrovalvula 3 |
afsaavedram | 0:6cde030caebb | 11 | DigitalOut E_4(D12); //Control de electrovalvula 4 |
afsaavedram | 0:6cde030caebb | 12 | AnalogIn sensor_nivel(A0); //Sensor nivel tanque 1 |
afsaavedram | 0:6cde030caebb | 13 | /*****************************************************/ |
afsaavedram | 0:6cde030caebb | 14 | |
afsaavedram | 0:6cde030caebb | 15 | /*******************INTERRUPCIONES********************/ |
afsaavedram | 0:6cde030caebb | 16 | |
afsaavedram | 0:6cde030caebb | 17 | InterruptIn button(USER_BUTTON); |
afsaavedram | 0:6cde030caebb | 18 | Timeout t_1; |
afsaavedram | 0:6cde030caebb | 19 | Timeout t_2; |
afsaavedram | 0:6cde030caebb | 20 | Timeout t_3; |
afsaavedram | 0:6cde030caebb | 21 | Timeout t_4; |
afsaavedram | 0:6cde030caebb | 22 | |
afsaavedram | 0:6cde030caebb | 23 | //tiempos de usuario |
afsaavedram | 0:6cde030caebb | 24 | float temp_user_1=0; //tiempo tope de electrocoagulacion |
afsaavedram | 0:6cde030caebb | 25 | float temp_user_2=0; //tiempo tope de reposo de la vinaza |
afsaavedram | 0:6cde030caebb | 26 | float temp_user_3=0; //tiempo tope de vaciado del agua en el tanque 2 |
afsaavedram | 0:6cde030caebb | 27 | float temp_user_4=0; //tiempo tope de vaciado de residuos en el tanque 2 |
afsaavedram | 0:6cde030caebb | 28 | |
afsaavedram | 0:6cde030caebb | 29 | |
afsaavedram | 0:6cde030caebb | 30 | |
afsaavedram | 0:6cde030caebb | 31 | |
afsaavedram | 0:6cde030caebb | 32 | /********************TECLADO Y LCD***********************/ |
afsaavedram | 0:6cde030caebb | 33 | |
afsaavedram | 0:6cde030caebb | 34 | // rs, e,d4,d5,d6,d7 |
afsaavedram | 0:6cde030caebb | 35 | TextLCD lcd(PC_8,PC_9,PC_10,PC_11,PC_12,PD_2); |
afsaavedram | 0:6cde030caebb | 36 | |
afsaavedram | 0:6cde030caebb | 37 | |
afsaavedram | 0:6cde030caebb | 38 | Keypad keypad(D3, D2, D1, D0, D7, D6, D5, D4); |
afsaavedram | 0:6cde030caebb | 39 | float num=0; |
afsaavedram | 0:6cde030caebb | 40 | char cadena[3]= {' ',' ',' '}; |
afsaavedram | 0:6cde030caebb | 41 | int llena=0; //verificar que la entrada es de 3 numeros |
afsaavedram | 0:6cde030caebb | 42 | |
afsaavedram | 0:6cde030caebb | 43 | |
afsaavedram | 0:6cde030caebb | 44 | /*********************FUNCIONES**************************/ |
afsaavedram | 0:6cde030caebb | 45 | |
afsaavedram | 0:6cde030caebb | 46 | void stop() //STOP |
afsaavedram | 0:6cde030caebb | 47 | { |
afsaavedram | 0:6cde030caebb | 48 | |
afsaavedram | 0:6cde030caebb | 49 | while(1) { |
afsaavedram | 0:6cde030caebb | 50 | lcd.cls(); |
afsaavedram | 0:6cde030caebb | 51 | } |
afsaavedram | 0:6cde030caebb | 52 | } |
afsaavedram | 0:6cde030caebb | 53 | |
afsaavedram | 0:6cde030caebb | 54 | bool electro_1() |
afsaavedram | 0:6cde030caebb | 55 | { |
afsaavedram | 0:6cde030caebb | 56 | E_1=!E_1; |
afsaavedram | 0:6cde030caebb | 57 | return E_1; |
afsaavedram | 0:6cde030caebb | 58 | } |
afsaavedram | 0:6cde030caebb | 59 | |
afsaavedram | 0:6cde030caebb | 60 | bool electro_2() |
afsaavedram | 0:6cde030caebb | 61 | { |
afsaavedram | 0:6cde030caebb | 62 | E_2=!E_2; |
afsaavedram | 0:6cde030caebb | 63 | return E_2; |
afsaavedram | 0:6cde030caebb | 64 | } |
afsaavedram | 0:6cde030caebb | 65 | |
afsaavedram | 0:6cde030caebb | 66 | bool electro_3() |
afsaavedram | 0:6cde030caebb | 67 | { |
afsaavedram | 0:6cde030caebb | 68 | E_3=!E_3; |
afsaavedram | 0:6cde030caebb | 69 | return E_3; |
afsaavedram | 0:6cde030caebb | 70 | } |
afsaavedram | 0:6cde030caebb | 71 | |
afsaavedram | 0:6cde030caebb | 72 | bool electro_4() |
afsaavedram | 0:6cde030caebb | 73 | { |
afsaavedram | 0:6cde030caebb | 74 | E_4=!E_4; |
afsaavedram | 0:6cde030caebb | 75 | return E_4; |
afsaavedram | 0:6cde030caebb | 76 | } |
afsaavedram | 0:6cde030caebb | 77 | /***********************MAIN***************************/ |
afsaavedram | 0:6cde030caebb | 78 | |
afsaavedram | 0:6cde030caebb | 79 | int main() |
afsaavedram | 0:6cde030caebb | 80 | { |
afsaavedram | 0:6cde030caebb | 81 | button.rise(&stop); |
afsaavedram | 0:6cde030caebb | 82 | keypad.enablePullUp(); |
afsaavedram | 0:6cde030caebb | 83 | wait(1); |
afsaavedram | 0:6cde030caebb | 84 | lcd.locate(0,0); |
afsaavedram | 0:6cde030caebb | 85 | lcd.printf(" Control para\n"); |
afsaavedram | 0:6cde030caebb | 86 | lcd.locate(0,1); |
afsaavedram | 0:6cde030caebb | 87 | lcd.printf("electrocoagular\n"); |
afsaavedram | 0:6cde030caebb | 88 | wait(3); |
afsaavedram | 0:6cde030caebb | 89 | lcd.cls(); |
afsaavedram | 0:6cde030caebb | 90 | |
afsaavedram | 0:6cde030caebb | 91 | while(1) { |
afsaavedram | 0:6cde030caebb | 92 | lcd.locate(0,0); |
afsaavedram | 0:6cde030caebb | 93 | lcd.printf("t_1=%f",temp_user_1); |
afsaavedram | 0:6cde030caebb | 94 | lcd.locate(8,0); |
afsaavedram | 0:6cde030caebb | 95 | lcd.printf("t_2=%f",temp_user_2); |
afsaavedram | 0:6cde030caebb | 96 | lcd.locate(0,1); |
afsaavedram | 0:6cde030caebb | 97 | lcd.printf("t_3=%f",temp_user_3); |
afsaavedram | 0:6cde030caebb | 98 | lcd.locate(8,1); |
afsaavedram | 0:6cde030caebb | 99 | lcd.printf("t_4=%f",temp_user_4); |
afsaavedram | 0:6cde030caebb | 100 | |
afsaavedram | 0:6cde030caebb | 101 | char key = keypad.getKey(); |
afsaavedram | 0:6cde030caebb | 102 | // if(key=='A'){temp_user_1=10;} |
afsaavedram | 0:6cde030caebb | 103 | |
afsaavedram | 0:6cde030caebb | 104 | if(key=='A'){ |
afsaavedram | 0:6cde030caebb | 105 | } |
afsaavedram | 0:6cde030caebb | 106 | |
afsaavedram | 0:6cde030caebb | 107 | |
afsaavedram | 0:6cde030caebb | 108 | |
afsaavedram | 0:6cde030caebb | 109 | |
afsaavedram | 0:6cde030caebb | 110 | |
afsaavedram | 0:6cde030caebb | 111 | }//termina while de main |
afsaavedram | 0:6cde030caebb | 112 | }//termina main |