operacion con botones incrementando y decrementando 1 en 1

Dependencies:   Debounced TextLCD mbed

Fork of pid_1 by Santiago Alvarez

Files at this revision

API Documentation at this revision

Comitter:
salvarear
Date:
Tue Dec 03 20:00:17 2013 +0000
Commit message:
d

Changed in this revision

Debounced.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Debounced.lib	Tue Dec 03 20:00:17 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/WarwickRacing/code/Debounced/#8992c13bbb9b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Tue Dec 03 20:00:17 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 03 20:00:17 2013 +0000
@@ -0,0 +1,105 @@
+#include "mbed.h"
+#include "DebouncedIn.h"
+#include "TextLCD.h"
+AnalogIn Vin(PTC2);
+TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7  //documentacion de las librerias y disposicion de pines
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DebouncedIn b1(PTC12);
+DebouncedIn b2(PTC13);
+DebouncedIn b3(PTC16);
+DebouncedIn b4(PTC17);
+     
+
+int C1=0x0E; // solo muestra el cursor
+int C2=0x18; // desplaza el cursor a la  izquierda
+int C3=0x1A; // desplaza el cursor derecha
+int C4=0x1C; // quita el  cursor bajo
+int a; 
+int b;
+int kp, ki, kd, sp, err, med, yr, pid, ap, ai, ad, err_v, cycle; //revisar antes de la primera tarear(PID)
+
+int main() {
+    lcd.cls();
+    lcd.printf("Sp%d",sp);      //ubicacion de las variables en la pantalla
+    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.writeCommand(C1);
+    lcd.locate(0,0);
+    lcd.printf("Sp%d",sp);
+
+
+    while(1) {              //inicio cliclos del pid
+        if (b1.falling()) { // incrementa
+           led1 =!led1;
+           ++a;
+           lcd.locate(7,0);
+           lcd.printf("%d", a);
+        }
+    if (b2.falling()) { //decrementa
+           led2 =!led2;
+           --a;
+           lcd.locate(7,0); lcd.printf("   ");
+           lcd.locate(7,0);
+           lcd.printf("%d", a);
+  
+     if (b3.falling()) { 
+                       
+          ++b;      
+                                              //cambia la posicion del menu
+     if (b==0){
+         lcd.locate(2,0);
+         lcd.printf("%d",sp);
+             if (b1.falling()) {                            
+             ++sp;                 //incrementa el sp
+             }
+               if (b2.falling()) {                            
+               --sp;                 //decrementa el sp
+               } 
+       }
+        if (b==1) {                  //posiciones de los botones
+           lcd.locate(10,0);
+           lcd.printf("%d",kp);
+            if (b1.falling()) {
+                ++kp;
+             }
+             if (b2.falling()) {                            
+                 --kp;
+              }
+          }
+          if (b==2) {
+            lcd.locate(2,1);
+            lcd.printf("%d",ki);
+                  if (b1.falling()){
+                     ++ki;
+                  }
+                  if (b2.falling()){                            
+                     --ki;
+                  }               
+              }
+           if (b==3) {
+               lcd.locate(10,1);
+               lcd.printf("%d",kd);
+                  if (b1.falling()){
+                     ++kd;
+                  }
+                  if (b2.falling()){                            
+                     --kd;
+                  }
+              } 
+            }  
+           if (b==4) {
+               b=0;
+               }                          
+    
+           if (b4.falling()){
+           break;                       //sale del menu de trabajo
+               }
+  }                      
+}
+}         
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 03 20:00:17 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file