Incrementar por medio de pulsadores
Dependencies: Debounced TextLCD mbed
Diff: main.cpp
- Revision:
- 0:7ac8f5f3e58b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Dec 13 17:31:13 2013 +0000 @@ -0,0 +1,118 @@ +#include "mbed.h" +#include "DebouncedIn.h" +#include "TextLCD.h" + +AnalogIn Vin(PTC2); +TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 +DigitalOut l1(LED1); +DigitalOut l2(LED2); +DebouncedIn b1(PTC12); +DebouncedIn b2(PTC13); +DebouncedIn b3(PTA1); +int c1=0x0E,i,k=1; + +int main() +{ + while(k==1) { + lcd.cls(); + lcd.writeCommand(c1); + lcd.locate(0,0); + lcd.printf("SP= %d",i); + lcd.locate(11,0); + lcd.printf("KP= %d",i); + lcd.locate(0,1); + lcd.printf("Ki= %d",i); + lcd.locate(11,1); + lcd.printf("Kd= %d",i); + + while(k==1) { + + if(b1.falling()) { + l1 = !l1; + ++i; + lcd.locate(3,0); + lcd.printf("%d",i); + } + if (b2.falling() && i>=1) { + l2 = !l2; + --i; + lcd.locate(3,0); + lcd.printf("%d",i); + } + if (b3.falling()) { + k+=1; + i=0; + } + + } + + + while(k==2) { + + if(b1.falling()) { + l1 = !l1; + ++i; + lcd.locate(14,0); + lcd.printf("%d",i); + } + if (b2.falling() && i>=1) { + l2 = !l2; + --i; + lcd.locate(14,0); + lcd.printf("%d",i); + } + if (b3.falling()) { + k+=1; + i=0; + } + + } + + + while(k==3) { + + if(b1.falling()) { + l1 = !l1; + ++i; + lcd.locate(3,1); + lcd.printf("%d",i); + } + if (b2.falling() && i>=1) { + l2 = !l2; + --i; + lcd.locate(3,1); + lcd.printf("%d",i); + } + if (b3.falling()) { + k+=1; + i=0; + } + + } + + + while(k==4) { + + if(b1.falling()) { + l1 = !l1; + ++i; + lcd.locate(14,1); + lcd.printf("%d",i); + } + if (b2.falling() && i>=1) { + l2 = !l2; + --i; + lcd.locate(14,1); + lcd.printf("%d",i); + } + if (b3.falling()) { + k=1; + i=0; + } + continue; + } + + } + +} +