![](/media/cache/profiles/53015ad3b6bbbf80a4d107e6ef603b1e.jpg.50x50_q85.jpg)
impresion en LCD con boton de incremento y decremento encada variable en el LCD
Diff: main.cpp
- Revision:
- 0:6c9cb98ad497
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 16 16:38:18 2013 +0000 @@ -0,0 +1,121 @@ +#include "mbed.h" +#include "DebouncedIn.h" +#include "TextLCD.h" + +TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 +int i,Sp=0,Kp,Ki,Kd; +DigitalOut l1(LED1); +DigitalOut l2(LED2); +int main() +{ + DebouncedIn button1(PTC12); + DebouncedIn button2(PTC13); + DebouncedIn button3(PTC16); + lcd.writeCommand(0x0E); + lcd.printf("Sp= Kp="); + lcd.locate(0,1); + lcd.printf("Ki= Kd="); + lcd.locate(2,0); + lcd.printf("="); + + while(1) { + + if(button1.falling()) { + + switch(i) { + case 0: + lcd.locate(2,0); + lcd.printf("= "); + lcd.locate(3,0); + lcd.printf("%d",++Sp); + + break; + case 1: + lcd.locate(10,0); + lcd.printf("= "); + lcd.locate(11,0); + lcd.printf("%d",++Kp); + break; + case 2: + + lcd.locate(2,1); + lcd.printf("= "); + lcd.locate(3,1); + lcd.printf("%d",++Ki); + break; + case 3: + lcd.locate(10,1); + lcd.printf("= "); + lcd.locate(11,1); + lcd.printf("%d",++Kd); + break; + } + } + if(button2.falling()) { + switch(i) { + case 0: + if(Sp<0) { + Sp=0; + } + lcd.locate(2,0); + lcd.printf("= "); + lcd.locate(3,0); + lcd.printf("%d",Sp--); + break; + case 1: + if(Kp<0) { + Kp=0; + } + lcd.locate(10,0); + lcd.printf("= "); + lcd.locate(11,0); + lcd.printf("%d",Kp--); + break; + case 2: + + if(Ki<0) { + Ki=0; + } + lcd.locate(2,1); + lcd.printf("= "); + lcd.locate(3,1); + lcd.printf("%d",Ki--); + break; + case 3: + + if(Kd<0) { + Kd=0; + } + lcd.locate(10,1); + lcd.printf("= "); + lcd.locate(11,1); + lcd.printf("%d",Kd--); + break; + } + } + if(button3.falling()) { + i++; + if(i>3) { + i=0; + } + switch (i) { + case 0: + lcd.locate(2,0); + lcd.printf("="); + break; + case 1: + lcd.locate(10,0); + lcd.printf("="); + break; + case 2: + lcd.locate(2,1); + lcd.printf("="); + break; + case 3: + lcd.locate(10,1); + lcd.printf("="); + break; + } + } + } +} \ No newline at end of file