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.
Dependencies: Debounced TextLCDmo mbed
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 #include "DebouncedIn.h" 00004 00005 TextLCD lcd(PTC10, PTC11, PTC12, PTC13, PTC16, PTC17); // rs, e, d4-d7.. Nota: No se quiere función de lectura, luego ese puerto a tierra. 00006 //lectura=1, escritura=0 00007 00008 00009 PwmOut rled(LED_BLUE); 00010 00011 DebouncedIn next(PTE2); 00012 DebouncedIn up(PTE3); 00013 DebouncedIn down(PTE4); 00014 00015 int C1=0x0F; 00016 00017 00018 int main() { 00019 00020 int c; 00021 int v,b,n,m; 00022 v=0; 00023 b=0; 00024 n=0; 00025 m=0; 00026 c=0; 00027 00028 lcd.cls(); 00029 lcd.locate(0,0); 00030 lcd.printf("sp:%d",v); 00031 lcd.locate(8,0); 00032 lcd.printf("kp:%d",b); 00033 lcd.locate(0,1); 00034 lcd.printf("ki:%d",n); 00035 lcd.locate(8,1); 00036 lcd.printf("kd:%d",m); 00037 00038 //SP 00039 00040 while (1){ 00041 00042 if (next.falling()){ 00043 c++; 00044 00045 while (c>3){ 00046 c=0; 00047 } 00048 00049 //Salto a SP 00050 if (c==0){ 00051 00052 lcd.locate(3,0); 00053 lcd.putc(0xFE); 00054 lcd.writeCommand(C1); 00055 lcd.locate(3,0); 00056 lcd.printf("%d",v); 00057 00058 while(c==0){ 00059 if(up.falling()){ 00060 v++; 00061 lcd.locate(3,0); 00062 lcd.printf("%d",v); 00063 } 00064 if(down.falling()){ 00065 v--; 00066 if(v<0){ 00067 v=0; 00068 lcd.locate(4,0); 00069 lcd.putc(0xFE); 00070 } 00071 if(v<10){ 00072 lcd.locate(4,0); 00073 lcd.putc(0xFE); 00074 } 00075 lcd.locate(3,0); 00076 lcd.printf("%d",v); 00077 } 00078 00079 if(next.falling()){ 00080 c++; 00081 } 00082 } 00083 } 00084 00085 00086 //Salto a Kp 00087 if (c==1){ 00088 00089 lcd.locate(11,0); 00090 lcd.putc(0xFE); 00091 lcd.writeCommand(C1); 00092 lcd.locate(11,0); 00093 lcd.printf("%d",b); 00094 00095 while(c==1){ 00096 if(up.falling()){ 00097 b++; 00098 lcd.locate(11,0); 00099 lcd.printf("%d",b); 00100 } 00101 if(down.falling()){ 00102 b--; 00103 if(b<0){ 00104 b=0; 00105 lcd.locate(12,0); 00106 lcd.putc(0xFE); 00107 } 00108 if(b<10){ 00109 lcd.locate(12,0); 00110 lcd.putc(0xFE); 00111 } 00112 lcd.locate(11,0); 00113 lcd.printf("%d",b); 00114 } 00115 00116 if(next.falling()){ 00117 c++; 00118 } 00119 } 00120 } 00121 00122 //Salto a Kp 00123 if (c==2){ 00124 00125 lcd.locate(3,1); 00126 lcd.putc(0xFE); 00127 lcd.writeCommand(C1); 00128 lcd.locate(3,1); 00129 lcd.printf("%d",n); 00130 00131 while(c==2){ 00132 if(up.falling()){ 00133 n++; 00134 lcd.locate(3,1); 00135 lcd.printf("%d",n); 00136 } 00137 if(down.falling()){ 00138 n--; 00139 if(n<0){ 00140 n=0; 00141 lcd.locate(4,1); 00142 lcd.putc(0xFE); 00143 } 00144 if(n<10){ 00145 lcd.locate(4,1); 00146 lcd.putc(0xFE); 00147 } 00148 lcd.locate(3,1); 00149 lcd.printf("%d",n); 00150 } 00151 00152 if(next.falling()){ 00153 c++; 00154 } 00155 } 00156 } 00157 00158 //Salto a Kp 00159 if (c==3){ 00160 00161 lcd.locate(11,1); 00162 lcd.putc(0xFE); 00163 lcd.writeCommand(C1); 00164 lcd.locate(11,1); 00165 lcd.printf("%d",m); 00166 00167 while(c==3){ 00168 if(up.falling()){ 00169 m++; 00170 lcd.locate(11,1); 00171 lcd.printf("%d",m); 00172 } 00173 if(down.falling()){ 00174 m--; 00175 if(m<0){ 00176 m=0; 00177 lcd.locate(12,1); 00178 lcd.putc(0xFE); 00179 } 00180 if(m<10){ 00181 lcd.locate(12,1); 00182 lcd.putc(0xFE); 00183 } 00184 lcd.locate(11,1); 00185 lcd.printf("%d",m); 00186 } 00187 00188 if(next.falling()){ 00189 c++; 00190 } 00191 } 00192 } 00193 00194 // 00195 } 00196 } 00197 }
Generated on Fri Jul 15 2022 08:10:27 by
1.7.2