yyyy

Dependencies:   TextLCD mbed

Revision:
0:cb40712c8750
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Apr 06 17:17:55 2016 +0000
@@ -0,0 +1,134 @@
+
+
+#include "mbed.h"
+#include "TextLCD.h" //Librería para control de display LCD
+DigitalIn boton1(D6);
+DigitalIn boton2(D7);
+DigitalIn boton3(D8);
+DigitalIn boton4(D9);
+DigitalIn boton5(D10);
+DigitalIn boton6(D11);
+DigitalOut alarma(D12);
+TextLCD lcd(D0, D1, D2, D3, D4, D5); 
+
+
+int seg1=0; //unidades de segundo
+int seg2=0; //décimas de segundo
+int min1=0; //unidades de minuto
+int min2=0; //décimas de minuto
+int i,s;
+
+int v=0;
+int l=0;
+int p=0;
+
+void reloj(){
+    lcd.locate(9,0);//unidades de segundo
+    lcd.printf("%d", seg1);
+    lcd.locate(8,0);//décimas de segundo
+    lcd.printf("%d",seg2);
+    lcd.locate(7,0);
+    lcd.printf(":");
+    lcd.locate(6,0);//unidades de minuto
+    lcd.printf("%d",min1);
+    lcd.locate(5,0);//décimas de minuto
+    lcd.printf("%d",min2);
+  
+}
+ 
+ 
+int main() {
+    
+    lcd.cls(); 
+    lcd.locate(0, 0); 
+    lcd.printf("TIEM"); 
+    
+    lcd.locate(11, 0);
+    lcd.printf("PER");
+    
+    lcd.locate(3, 1);
+    lcd.printf("HOME");
+    
+    lcd.locate(7, 1);
+    lcd.printf(":");
+    
+    lcd.locate(8, 1);
+    lcd.printf("GUES");
+    
+    
+    while (1){
+        
+        if(min1>=2){
+          alarma=1;  
+            }
+        
+        if(boton5==1){
+            l++;
+            wait(.2);
+            lcd.locate(0, 1);
+    lcd.printf("%d",l);
+            }
+            
+            if(boton4==1){
+            v++;
+            wait(.2);
+            lcd.locate(13, 1);
+    lcd.printf("%d",v);
+            }
+            
+             if(boton6==1){
+            p++;
+            wait(.2);
+            lcd.locate(15, 0);
+    lcd.printf("%d",p);
+            }
+            
+            
+            
+            
+        if(boton1==1){
+            i=1;
+           s=1;
+            }
+             if(boton2==1){
+            s=0;
+            wait(.2);
+            }
+            
+            if(i==1&&s==1){    
+          if(boton3==1){     
+           min1=0;
+           min2=0;
+           seg1=0;
+           seg2=0; 
+           i=0;
+           
+           }
+            
+        reloj(); 
+            
+        seg1++; //Inician contador 
+        wait(1); 
+        if (seg1==10){
+            seg2++;//décimas de segundo
+            seg1=0;
+            if (seg2==6){
+                min1++;//Contador unidades de minuto
+                seg2=0;
+                if (min1==10){
+                    min2++;//Contador décimas de minuto
+                    min1=0;
+                            if((min1==2)&&(min2==4)){
+                                min1=0;
+                                min2=0;
+                                seg1=0;
+                                seg2=0;
+                          
+                        }
+                    }
+                }
+            }
+        }  
+       }
+    
+}
\ No newline at end of file