Incrementar por medio de pulsadores
Dependencies: Debounced TextLCD mbed
main.cpp
00001 #include "mbed.h" 00002 #include "DebouncedIn.h" 00003 #include "TextLCD.h" 00004 00005 AnalogIn Vin(PTC2); 00006 TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 00007 DigitalOut l1(LED1); 00008 DigitalOut l2(LED2); 00009 DebouncedIn b1(PTC12); 00010 DebouncedIn b2(PTC13); 00011 DebouncedIn b3(PTA1); 00012 int c1=0x0E,i,k=1; 00013 00014 int main() 00015 { 00016 while(k==1) { 00017 lcd.cls(); 00018 lcd.writeCommand(c1); 00019 lcd.locate(0,0); 00020 lcd.printf("SP= %d",i); 00021 lcd.locate(11,0); 00022 lcd.printf("KP= %d",i); 00023 lcd.locate(0,1); 00024 lcd.printf("Ki= %d",i); 00025 lcd.locate(11,1); 00026 lcd.printf("Kd= %d",i); 00027 00028 while(k==1) { 00029 00030 if(b1.falling()) { 00031 l1 = !l1; 00032 ++i; 00033 lcd.locate(3,0); 00034 lcd.printf("%d",i); 00035 } 00036 if (b2.falling() && i>=1) { 00037 l2 = !l2; 00038 --i; 00039 lcd.locate(3,0); 00040 lcd.printf("%d",i); 00041 } 00042 if (b3.falling()) { 00043 k+=1; 00044 i=0; 00045 } 00046 00047 } 00048 00049 00050 while(k==2) { 00051 00052 if(b1.falling()) { 00053 l1 = !l1; 00054 ++i; 00055 lcd.locate(14,0); 00056 lcd.printf("%d",i); 00057 } 00058 if (b2.falling() && i>=1) { 00059 l2 = !l2; 00060 --i; 00061 lcd.locate(14,0); 00062 lcd.printf("%d",i); 00063 } 00064 if (b3.falling()) { 00065 k+=1; 00066 i=0; 00067 } 00068 00069 } 00070 00071 00072 while(k==3) { 00073 00074 if(b1.falling()) { 00075 l1 = !l1; 00076 ++i; 00077 lcd.locate(3,1); 00078 lcd.printf("%d",i); 00079 } 00080 if (b2.falling() && i>=1) { 00081 l2 = !l2; 00082 --i; 00083 lcd.locate(3,1); 00084 lcd.printf("%d",i); 00085 } 00086 if (b3.falling()) { 00087 k+=1; 00088 i=0; 00089 } 00090 00091 } 00092 00093 00094 while(k==4) { 00095 00096 if(b1.falling()) { 00097 l1 = !l1; 00098 ++i; 00099 lcd.locate(14,1); 00100 lcd.printf("%d",i); 00101 } 00102 if (b2.falling() && i>=1) { 00103 l2 = !l2; 00104 --i; 00105 lcd.locate(14,1); 00106 lcd.printf("%d",i); 00107 } 00108 if (b3.falling()) { 00109 k=1; 00110 i=0; 00111 } 00112 continue; 00113 } 00114 00115 } 00116 00117 } 00118
Generated on Mon Jul 18 2022 21:22:21 by 1.7.2