Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 00002 #include "mbed.h" 00003 #include "TextLCD.h" 00004 /* 00005 #define MODO 0 00006 #define ESTERELIZADO 1 00007 #define ESC_RAPIDO 2 00008 #define ESC_LENTO 3 00009 #define SECADO 4 00010 #define DRENADO 5 00011 */ 00012 DigitalOut green(LED2); 00013 DigitalOut valvula(D4); 00014 DigitalIn Select(PC_10); 00015 DigitalIn Acept(PC_11); 00016 DigitalIn Abort(PD_2); 00017 AnalogIn AnaValue(A1); 00018 00019 TextLCD lcd1(PC_2,PC_3,PC_0,PC_1,PB_0,PA_4); // rs, e, d4-d7 00020 TextLCD lcd2(PC_12,PA_13,PA_14,PA_15,PB_7,PC_13); // rs, e, d4-d7 00021 00022 //DigitalOut led_a(PC_10); 00023 //DigitalOut led_b(PC_11); 00024 //DigitalOut led_c(PC_12); 00025 //DigitalOut led_d(PD_2); 00026 //DigitalOut led_e(PA_13); 00027 //DigitalIn Abort(RESET_BUTTON); 00028 00029 unsigned char final_value; 00030 void readtemp(){ 00031 float value = 0; 00032 value = AnaValue.read(); 00033 value = (value*3300)/10; 00034 final_value = (int)value; 00035 } 00036 unsigned char read_button(DigitalIn button){ 00037 unsigned hold_up = 0; 00038 unsigned hold_down = 0; 00039 while(1){ 00040 if(button.read()) { 00041 hold_up++; 00042 } else { 00043 hold_down++; 00044 } 00045 if((hold_up > 500000) || (hold_down > 500000)){ 00046 break; 00047 } 00048 } 00049 if(hold_up >= hold_down) { 00050 return 1; 00051 } else { 00052 return 0; 00053 } 00054 } 00055 00056 typedef enum est{MODO,ESTERELIZADO,ESC_RAPIDO,ESC_LENTO,SECADO, DRENADO}Estado; 00057 00058 00059 int main() 00060 { 00061 unsigned char change = 0; 00062 unsigned counter = 0; 00063 valvula = 0; 00064 while(1) { 00065 lcd1.cls(); 00066 lcd2.cls(); 00067 lcd1.printf("Op. Actual: ModoOp. Select: Auto"); 00068 lcd2.printf("Seleccione "); 00069 while(!read_button(Acept)){ 00070 if(read_button(Select)){ 00071 change = !change; 00072 lcd1.cls(); 00073 if (change){ 00074 lcd1.printf("Op.Actual: Mode\nOp.Select: Auto"); 00075 valvula = 1; 00076 } else { 00077 lcd1.printf("Op.Actual: Mode\nOp.Select:Manual"); 00078 valvula = 0; 00079 } 00080 } 00081 if (read_button(Abort)){break;} 00082 } 00083 if(read_button(Acept)){wait(.01);} 00084 while(!read_button(Acept)) { 00085 lcd1.cls(); 00086 lcd2.cls(); 00087 readtemp(); 00088 lcd2.printf("Esterelizado\nOp.Select: Auto"); 00089 lcd1.printf("TpD %d TpC %d PsD %d PsC %d", final_value,final_value,final_value,final_value); 00090 if (read_button(Abort)){break;} 00091 } 00092 if(read_button(Acept)){wait(.01);} 00093 while(!read_button(Acept)) { 00094 lcd1.cls(); 00095 lcd2.cls(); 00096 readtemp(); 00097 lcd2.printf("Escape Rapido\nOp.Select: Auto"); 00098 lcd1.printf("TpD %d TpC %d PsD %d PsC %d", final_value,final_value,final_value,final_value); 00099 if (read_button(Abort)){break;} 00100 } 00101 if(read_button(Acept)){wait(.01);} 00102 while(!read_button(Acept)) { 00103 lcd1.cls(); 00104 lcd2.cls(); 00105 readtemp(); 00106 lcd2.printf("Escape Lento\nOp.Select: Auto"); 00107 lcd1.printf("TpD %d TpC %d PsD %d PsC %d", final_value,final_value,final_value,final_value); 00108 if (read_button(Abort)){break;} 00109 } 00110 if(read_button(Acept)){wait(.01);} 00111 while(!read_button(Acept)) { 00112 lcd1.cls(); 00113 lcd2.cls(); 00114 readtemp(); 00115 lcd2.printf("Secado\nOp.Select: Auto"); 00116 lcd1.printf("TpD %d TpC %d PsD %d PsC %d", final_value,final_value,final_value,final_value); 00117 if (read_button(Abort)){break;} 00118 } 00119 if(read_button(Acept)){wait(.01);} 00120 } 00121 }
Generated on Fri Aug 19 2022 11:39:18 by
1.7.2