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.
42prueba.cpp
00001 /*Se requiere un tablero digital implementado en un LCD. El sistema deberá mostrar la puntuación 00002 para un juego de hockey, en ambas porterías existen sensoresdenominado A y B que detectan 00003 cuando se anota un gol por lo que automáticamente se marcara el puntaje y tiene un botón para 00004 reiniciar la cuenta. El marcador debe ser mostrado en una pantalla como en el siguiente ejemplo: 00005 Linea 1 del LCD: LOCAL 05 00006 Linea 2 del LCD: VISITANTE 05 00007 */ 00008 #include "mbed.h" 00009 #include "TextLCD.h" 00010 00011 DigitalIn local(D14); 00012 DigitalIn visitante(D15); 00013 DigitalIn reinicio(D8); 00014 TextLCD lcd(D2,D3,A2,A3,A4,A5); // rs, e, d4-d7 00015 00016 int main() { 00017 while(1){ 00018 int suma1=0; 00019 int suma2=0; 00020 lcd.cls(); 00021 00022 lcd.cls(); 00023 for(int k=0;k<3;k++){ //adorno 00024 lcd.printf("**Inicio del**\n****juego****");wait(0.5);lcd.cls(); 00025 lcd.printf(" \n");wait(0.3);lcd.cls(); 00026 } 00027 00028 int val=1; 00029 while(val){ 00030 if(reinicio==1){ 00031 NVIC_SystemReset(); 00032 } 00033 if(local==1){ 00034 suma1=suma1+1; 00035 if(suma1==5){ 00036 for(int k=0;k<4;k++){ //adorno 00037 lcd.printf("*LOCAL*\n<===========");wait(0.4);lcd.cls(); 00038 lcd.printf("\n************");wait(0.2);lcd.cls(); 00039 lcd.printf("\n*GANADOR*");wait(0.4);lcd.cls(); 00040 lcd.printf("************\n");wait(0.2);lcd.cls(); 00041 } 00042 val=0; //para regresar al programa principal 00043 } 00044 else{ 00045 lcd.printf("L \n",suma1);wait(0.2);lcd.cls(); 00046 lcd.printf("OL \n",suma1);wait(0.2);lcd.cls(); 00047 lcd.printf("OOL \n",suma1);wait(0.2);lcd.cls(); 00048 lcd.printf("OOOL \n",suma1);wait(0.2);lcd.cls(); 00049 lcd.printf("GOOOL \n",suma1);wait(0.2);lcd.cls(); 00050 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00051 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00052 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00053 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00054 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00055 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00056 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00057 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00058 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00059 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00060 lcd.printf(" GOOOL\n",suma1);wait(0.2);lcd.cls(); 00061 lcd.printf(" GOOO\n",suma1);wait(0.2);lcd.cls(); 00062 lcd.printf(" GOO\n",suma1);wait(0.2);lcd.cls(); 00063 lcd.printf(" GO\n",suma1);wait(0.2);lcd.cls(); 00064 lcd.printf(" G\n",suma1);wait(0.2);lcd.cls(); 00065 lcd.printf(" \n");wait(0.3);lcd.cls(); 00066 } 00067 } 00068 if(visitante==1){ 00069 suma2=suma2+1; 00070 if(suma2==5){ 00071 for(int k=0;k<4;k++){ //adorno 00072 lcd.printf("*VISITANTE*\n===========>");wait(0.4);lcd.cls(); 00073 lcd.printf("\n************");wait(0.2);lcd.cls(); 00074 lcd.printf("\n*GANADOR*");wait(0.4);lcd.cls(); 00075 lcd.printf("************\n");wait(0.2);lcd.cls(); 00076 } 00077 val=0; //para regresar al programa principal 00078 } 00079 else{ 00080 lcd.printf("L \n",suma1);wait(0.2);lcd.cls(); 00081 lcd.printf("OL \n",suma1);wait(0.2);lcd.cls(); 00082 lcd.printf("OOL \n",suma1);wait(0.2);lcd.cls(); 00083 lcd.printf("OOOL \n",suma1);wait(0.2);lcd.cls(); 00084 lcd.printf("GOOOL \n",suma1);wait(0.2);lcd.cls(); 00085 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00086 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00087 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00088 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00089 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00090 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00091 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00092 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00093 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00094 lcd.printf(" GOOOL \n",suma1);wait(0.2);lcd.cls(); 00095 lcd.printf(" GOOOL\n",suma1);wait(0.2);lcd.cls(); 00096 lcd.printf(" GOOO\n",suma1);wait(0.2);lcd.cls(); 00097 lcd.printf(" GOO\n",suma1);wait(0.2);lcd.cls(); 00098 lcd.printf(" GO\n",suma1);wait(0.2);lcd.cls(); 00099 lcd.printf(" G\n",suma1);wait(0.2);lcd.cls(); 00100 lcd.printf(" \n");wait(0.3);lcd.cls(); 00101 } 00102 } 00103 else{//mostrando marcador 00104 lcd.printf("LOCAL= %i \nVISITANTE= %i",suma1,suma2);wait(0.2);lcd.cls(); 00105 lcd.printf("\n");wait(0.001);lcd.cls(); 00106 }//if prueba 00107 }//final while var 00108 //} //final if 00109 00110 for(int k=0;k<5;k++){ //adorno 00111 lcd.printf("*JUEGO*\n*FINALIZADO*");wait(0.5);lcd.cls(); 00112 lcd.printf("\n");wait(0.2);lcd.cls(); 00113 } 00114 lcd.printf("*\n");wait(0.1);lcd.cls(); 00115 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00116 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00117 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00118 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00119 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00120 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00121 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00122 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00123 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00124 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00125 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00126 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00127 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00128 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00129 lcd.printf(" *\n");wait(0.1);lcd.cls(); 00130 lcd.printf("\n");wait(0.2);lcd.cls(); 00131 00132 00133 }//fin if reinicio 00134 } //end while (1) 00135 //end int
Generated on Fri Jul 15 2022 00:44:03 by
1.7.2