As
Dependencies: DebouncedIn TextLCD mbed
Revision 0:cfae0be51e6b, committed 2014-03-28
- Comitter:
- lenteja2206
- Date:
- Fri Mar 28 03:22:48 2014 +0000
- Commit message:
- Jo
Changed in this revision
diff -r 000000000000 -r cfae0be51e6b DebouncedIn.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DebouncedIn.lib Fri Mar 28 03:22:48 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/cmorab/code/DebouncedIn/#dc1131de43e8
diff -r 000000000000 -r cfae0be51e6b TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Fri Mar 28 03:22:48 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r cfae0be51e6b main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.c Fri Mar 28 03:22:48 2014 +0000 @@ -0,0 +1,165 @@ +#include "mbed.h" +#include "DebouncedIn.h" +#include "TextLCD.h" + +AnalogIn Vin(PTC2); +AnalogOut Vout(PTC3); +TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 + +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DebouncedIn button1(PTC12); +DebouncedIn button2(PTC13); +DebouncedIn button3(PTC16); + +int C1=0x0F; +int sp=0,kp=0,kd=0,ki=0,p=1; +int main() +{ + lcd.cls(); + lcd.writeCommand(C1);//escribimos un comando segun el manual del modulo LCD + lcd.locate(8,0); + lcd.printf("kp=%d", kp); + lcd.locate(0,1); + lcd.printf("Ki=%d", ki); + lcd.locate(8,1); + lcd.printf("Kd=%d", kd); + lcd.locate(0,0); + lcd.printf("Sp=%d", sp); + + while(1) + { + if (button1.falling()) + { + + led1 =!led1; + if (p==1) + { + ++sp; + lcd.locate(3,0); + lcd.printf(" "); + lcd.locate(3,0); + lcd.printf("%d", sp); + } //Cierra sp + else if (p==2) + { + ++kp; + lcd.locate(11,0); + lcd.printf(" "); + lcd.locate(11,0); + lcd.printf("%d", kp); + } //Cierra kp + else if (p==3) + { + ++ki; + lcd.locate(3,1); + lcd.printf(" "); + lcd.locate(3,1); + lcd.printf("%d", ki); + } //Cierra ki + else if (p==4) + { + ++kd; + lcd.locate(11,1); + lcd.printf(" "); + lcd.locate(11,1); + lcd.printf("%d", kd); + } //Cierra kd + } //Cierra button1.falling + if (button2.falling()) + { + led2 =!led2; + if (p==1) + { + if (sp==0) // no mostrar nada + { + } + else + { + --sp; + lcd.locate(3,0); + lcd.printf(" "); + lcd.locate(3,0); + lcd.printf("%d", sp); + } //Cierra sp + } //Cierra if p==1 + if (p==2) + { + if (kp==0) // no mostrar nada + { + } + else + { + --kp; + lcd.locate(11,0); + lcd.printf(" "); + lcd.locate(11,0); + lcd.printf("%d", kp); + } //Cierra kp + } //Cierra if p==2 + if (p==3) + { + if (ki==0) // no mostrar nada + { + } + else + { + --ki; + lcd.locate(3,1); + lcd.printf(" "); + lcd.locate(3,1); + lcd.printf("%d", ki); + } //Cierra ki + } //Cierra if p==3 + if (p==4) + { + if (kd==0) // no mostrar nada + { + } + else + { + --kd; + lcd.locate(11,1); + lcd.printf(" "); + lcd.locate(11,1); + lcd.printf("%d", kd); + } //Cierra kd + } //Cierra if p==4 + } //Cierra button2.falling + if (button3.falling()) + { + led3 =!led3; + if (p==1) + { + ++p; + lcd.locate(11,0); + lcd.printf("%d", kp); + + + } + else if (p==2) + { + ++p; + lcd.locate(3,1); + lcd.printf("%d", ki); + lcd.locate(3,1); + + } + else if (p==3) + { + ++p; + lcd.locate(11,1); + lcd.printf("%d", kd); + } + else if (p==4) + { + p=1; + lcd.locate(3,0); + lcd.printf("%d", sp); + + + } + } + } +}
diff -r 000000000000 -r cfae0be51e6b mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Mar 28 03:22:48 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7d30d6019079 \ No newline at end of file