Alejandro Marin
/
Tarea1procesadores
impresion en LCD con boton de incremento y decremento encada variable en el LCD
main.cpp
- Committer:
- amarincan
- Date:
- 2013-10-16
- Revision:
- 0:6c9cb98ad497
File content as of revision 0:6c9cb98ad497:
#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; } } } }