Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 00002 00003 #include "mbed.h" 00004 #include "TextLCD.h" //Librería para control de display LCD 00005 DigitalIn boton1(D6); 00006 DigitalIn boton2(D7); 00007 DigitalIn boton3(D8); 00008 DigitalIn boton4(D9); 00009 DigitalIn boton5(D10); 00010 DigitalIn boton6(D11); 00011 DigitalOut alarma(D12); 00012 TextLCD lcd(D0, D1, D2, D3, D4, D5); 00013 00014 00015 int seg1=0; //unidades de segundo 00016 int seg2=0; //décimas de segundo 00017 int min1=0; //unidades de minuto 00018 int min2=0; //décimas de minuto 00019 int i,s; 00020 00021 int v=0; 00022 int l=0; 00023 int p=0; 00024 00025 void reloj(){ 00026 lcd.locate(9,0);//unidades de segundo 00027 lcd.printf("%d", seg1); 00028 lcd.locate(8,0);//décimas de segundo 00029 lcd.printf("%d",seg2); 00030 lcd.locate(7,0); 00031 lcd.printf(":"); 00032 lcd.locate(6,0);//unidades de minuto 00033 lcd.printf("%d",min1); 00034 lcd.locate(5,0);//décimas de minuto 00035 lcd.printf("%d",min2); 00036 00037 } 00038 00039 00040 int main() { 00041 00042 lcd.cls(); 00043 lcd.locate(0, 0); 00044 lcd.printf("TIEM"); 00045 00046 lcd.locate(11, 0); 00047 lcd.printf("PER"); 00048 00049 lcd.locate(3, 1); 00050 lcd.printf("HOME"); 00051 00052 lcd.locate(7, 1); 00053 lcd.printf(":"); 00054 00055 lcd.locate(8, 1); 00056 lcd.printf("GUES"); 00057 00058 00059 while (1){ 00060 00061 if(min1>=2){ 00062 alarma=1; 00063 } 00064 00065 if(boton5==1){ 00066 l++; 00067 wait(.2); 00068 lcd.locate(0, 1); 00069 lcd.printf("%d",l); 00070 } 00071 00072 if(boton4==1){ 00073 v++; 00074 wait(.2); 00075 lcd.locate(13, 1); 00076 lcd.printf("%d",v); 00077 } 00078 00079 if(boton6==1){ 00080 p++; 00081 wait(.2); 00082 lcd.locate(15, 0); 00083 lcd.printf("%d",p); 00084 } 00085 00086 00087 00088 00089 if(boton1==1){ 00090 i=1; 00091 s=1; 00092 } 00093 if(boton2==1){ 00094 s=0; 00095 wait(.2); 00096 } 00097 00098 if(i==1&&s==1){ 00099 if(boton3==1){ 00100 min1=0; 00101 min2=0; 00102 seg1=0; 00103 seg2=0; 00104 i=0; 00105 00106 } 00107 00108 reloj(); 00109 00110 seg1++; //Inician contador 00111 wait(1); 00112 if (seg1==10){ 00113 seg2++;//décimas de segundo 00114 seg1=0; 00115 if (seg2==6){ 00116 min1++;//Contador unidades de minuto 00117 seg2=0; 00118 if (min1==10){ 00119 min2++;//Contador décimas de minuto 00120 min1=0; 00121 if((min1==2)&&(min2==4)){ 00122 min1=0; 00123 min2=0; 00124 seg1=0; 00125 seg2=0; 00126 00127 } 00128 } 00129 } 00130 } 00131 } 00132 } 00133 00134 }
Generated on Tue Jul 26 2022 17:04:29 by
1.7.2