Display 16x2 is used to counting numbers show, ascending or descending in 4 positions

Dependencies:   Debounced TextLCDmo mbed

Files at this revision

API Documentation at this revision

Comitter:
mandres7
Date:
Fri Oct 18 20:27:38 2013 +0000
Commit message:
counter in display 16x2 (sp,kp,ks,kd)

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
diff -r 000000000000 -r 7f914d2c35cb Debounced.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Debounced.lib	Fri Oct 18 20:27:38 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/WarwickRacing/code/Debounced/#8992c13bbb9b
diff -r 000000000000 -r 7f914d2c35cb TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Fri Oct 18 20:27:38 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mandres7/code/TextLCDmo/#da82f3666251
diff -r 000000000000 -r 7f914d2c35cb main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 18 20:27:38 2013 +0000
@@ -0,0 +1,197 @@
+#include "mbed.h"
+#include "TextLCD.h"
+#include "DebouncedIn.h"
+
+TextLCD lcd(PTC10, PTC11, PTC12, PTC13, PTC16, PTC17); // rs, e, d4-d7.. Nota: No se quiere función de lectura, luego ese puerto a tierra.
+//lectura=1, escritura=0
+
+
+PwmOut rled(LED_BLUE);
+
+DebouncedIn next(PTE2);
+DebouncedIn up(PTE3);
+DebouncedIn down(PTE4);
+
+int C1=0x0F; 
+
+
+int main() {
+
+int c;
+int v,b,n,m;
+v=0;
+b=0;
+n=0;
+m=0;
+c=0;
+
+lcd.cls();     
+lcd.locate(0,0);
+lcd.printf("sp:%d",v);
+lcd.locate(8,0);
+lcd.printf("kp:%d",b);
+lcd.locate(0,1);
+lcd.printf("ki:%d",n);
+lcd.locate(8,1);
+lcd.printf("kd:%d",m);
+
+//SP
+
+while (1){
+
+if (next.falling()){    
+        c++;
+        
+        while (c>3){
+        c=0;
+                 }              
+
+    //Salto a SP
+    if (c==0){
+        
+        lcd.locate(3,0);
+        lcd.putc(0xFE);                
+        lcd.writeCommand(C1);
+        lcd.locate(3,0);
+        lcd.printf("%d",v);
+        
+            while(c==0){    
+            if(up.falling()){
+                v++;
+                lcd.locate(3,0);
+                lcd.printf("%d",v);
+                               }
+            if(down.falling()){
+                v--;
+                if(v<0){
+                v=0;
+                lcd.locate(4,0);
+                lcd.putc(0xFE);                 
+                        }
+                if(v<10){                
+                lcd.locate(4,0);
+                lcd.putc(0xFE);                 
+                        }                        
+                lcd.locate(3,0);
+                lcd.printf("%d",v);               
+                                }  
+                
+             if(next.falling()){
+                c++;
+                }                                                             
+                }
+                } 
+              
+        
+    //Salto a Kp
+    if (c==1){
+        
+        lcd.locate(11,0);
+        lcd.putc(0xFE);                
+        lcd.writeCommand(C1);
+        lcd.locate(11,0);
+        lcd.printf("%d",b);
+        
+            while(c==1){    
+            if(up.falling()){
+                b++;
+                lcd.locate(11,0);
+                lcd.printf("%d",b);
+                               }
+            if(down.falling()){
+                b--;
+                if(b<0){
+                b=0;
+                lcd.locate(12,0);
+                lcd.putc(0xFE);                 
+                        }
+                if(b<10){                
+                lcd.locate(12,0);
+                lcd.putc(0xFE);                 
+                        }                        
+                lcd.locate(11,0);
+                lcd.printf("%d",b);               
+                                }  
+                
+             if(next.falling()){
+                c++;
+                }                                                             
+                }
+                }
+              
+    //Salto a Kp
+    if (c==2){
+        
+        lcd.locate(3,1);
+        lcd.putc(0xFE);                
+        lcd.writeCommand(C1);
+        lcd.locate(3,1);
+        lcd.printf("%d",n);
+        
+            while(c==2){    
+            if(up.falling()){
+                n++;
+                lcd.locate(3,1);
+                lcd.printf("%d",n);
+                               }
+            if(down.falling()){
+                n--;
+                if(n<0){
+                n=0;
+                lcd.locate(4,1);
+                lcd.putc(0xFE);                 
+                        }
+                if(n<10){                
+                lcd.locate(4,1);
+                lcd.putc(0xFE);                 
+                        }                        
+                lcd.locate(3,1);
+                lcd.printf("%d",n);               
+                                }  
+                
+             if(next.falling()){
+                c++;
+                }                                                             
+                }
+                }        
+
+    //Salto a Kp
+    if (c==3){
+        
+        lcd.locate(11,1);
+        lcd.putc(0xFE);                
+        lcd.writeCommand(C1);
+        lcd.locate(11,1);
+        lcd.printf("%d",m);
+        
+            while(c==3){    
+            if(up.falling()){
+                m++;
+                lcd.locate(11,1);
+                lcd.printf("%d",m);
+                               }
+            if(down.falling()){
+                m--;
+                if(m<0){
+                m=0;
+                lcd.locate(12,1);
+                lcd.putc(0xFE);                 
+                        }
+                if(m<10){                
+                lcd.locate(12,1);
+                lcd.putc(0xFE);                 
+                        }                        
+                lcd.locate(11,1);
+                lcd.printf("%d",m);               
+                                }  
+                
+             if(next.falling()){
+                c++;
+                }                                                             
+                }
+                }   
+    
+    //          
+                    }       
+}
+}        
\ No newline at end of file
diff -r 000000000000 -r 7f914d2c35cb mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Oct 18 20:27:38 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file