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.
Revision 0:df5d1a705b6d, committed 2018-09-26
- Comitter:
- hdzoisrael
- Date:
- Wed Sep 26 18:37:40 2018 +0000
- Commit message:
- tvvav
Changed in this revision
diff -r 000000000000 -r df5d1a705b6d 41prueba.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/41prueba.cpp Wed Sep 26 18:37:40 2018 +0000
@@ -0,0 +1,314 @@
+/*Proponga un programa que inicie con el mensaje “Contraseña” y obtenga 3 dígitos de contraseña
+mediante el teclado, visualizando en un LCD uno a uno de los caracteres, al obtener los tres dígitos
+visualizar la contraseña y esperar un segundo para mostrar el mensaje “acceso” recorriéndolo a la
+derecha y activar un actuador(relevador ó motor CD) durante2 segundo, el caso de ser incorrecto
+que aparezca “denegado” recorriendo el texto a la derecha durante 2 segundos, al finalizar que
+aparezca el texto “Contraseña”
+*/
+#include "mbed.h"
+#include "TextLCD.h"
+
+BusOut r(D8,D9,D10,D11);
+BusIn c(D12,D13,D14,D15);
+DigitalOut motor(D7);
+TextLCD lcd(D2,D3,A2,A3,A4,A5); // rs, e, d4-d7
+
+int main() {
+ while(1){
+ lcd.cls();
+ int c1='0';int c2='6';int c3='9';
+ int T1='0';
+ int T2='0';
+ int T3='0';
+ int val=1;
+ val=1;
+ while(val){
+ lcd.printf("Contrasena\n");wait(0.1);lcd.cls();
+ for (int i=0; i<4;i++){
+ r=1<<i;
+ switch(c){//switch 1
+ case 0x01:
+ switch(r){
+ case 0x01:
+ T1='1';lcd.printf("1\n");wait(0.5);lcd.cls();val=0;break;//1
+ case 0x02:
+ T1='4';lcd.printf("4\n");wait(0.5);lcd.cls();val=0;break;//4
+ case 0x04:
+ T1='7';lcd.printf("7\n");wait(0.5);lcd.cls();val=0;break;//7
+ case 0x08:
+ wait(0.1);break; //asterisco
+ }
+ break;
+ case 0x02:
+ switch(r){
+ case 0x01:
+ T1='2';lcd.printf("2\n");wait(0.5);lcd.cls();val=0;break;//2
+ case 0x02:
+ T1='5';lcd.printf("5\n");wait(0.5);lcd.cls();val=0;break;//5
+ case 0x04:
+ T1='8';lcd.printf("8\n");wait(0.5);lcd.cls();val=0;break;//8
+ case 0x08:
+ T1='0';lcd.printf("0\n");wait(0.5);lcd.cls();val=0;break; //0
+ }
+ break;
+ case 0x04:
+ switch(r){
+ case 0x01:
+ T1='3';lcd.printf("3\n");wait(0.5);lcd.cls();val=0;break;//3
+ case 0x02:
+ T1='6';lcd.printf("6\n");wait(0.5);lcd.cls();val=0;break;//6
+ case 0x04:
+ T1='9';lcd.printf("9\n");wait(0.5);lcd.cls();val=0;break;//9
+ case 0x08:
+ wait(0.1);break; //#
+ }
+ break;
+ case 0x08:
+ switch(r){
+ case 0x01:
+ wait(0.1);break;//A
+ case 0x02:
+ wait(0.1);break;//B
+ case 0x04:
+ wait(0.1);break;//C
+ case 0x08:
+ wait(0.1);break; //D
+ } //end switch2
+ break;
+ default:
+ wait(0.001);
+ break;
+ }//end switch1
+ }//end for
+ }//end while val
+
+ int val2=1;
+ val2=1;
+ while(val2){
+ for (int i=0; i<4;i++){
+ r=1<<i;
+ switch(c){//switch 1
+ case 0x01:
+ switch(r){
+ case 0x01:
+ T2='1';lcd.printf("1\n");wait(0.5);lcd.cls();val2=0;break;//1
+ case 0x02:
+ T2='4';lcd.printf("4\n");wait(0.5);lcd.cls();val2=0;break;//4
+ case 0x04:
+ T2='7';lcd.printf("7\n");wait(0.5);lcd.cls();val2=0;break;//7
+ case 0x08:
+ wait(0.1);break; //asterisco
+ }
+ break;
+ case 0x02:
+ switch(r){
+ case 0x01:
+ T2='2';lcd.printf("2\n");wait(0.5);lcd.cls();val2=0;break;//2
+ case 0x02:
+ T2='5';lcd.printf("5\n");wait(0.5);lcd.cls();val2=0;break;//5
+ case 0x04:
+ T2='8';lcd.printf("8\n");wait(0.5);lcd.cls();val2=0;break;//8
+ case 0x08:
+ T2='0';lcd.printf("0\n");wait(0.5);lcd.cls();val2=0;break; //0
+ }
+ break;
+ case 0x04:
+ switch(r){
+ case 0x01:
+ T2='3';lcd.printf("3\n");wait(0.5);lcd.cls();val2=0;break;//3
+ case 0x02:
+ T2='6';lcd.printf("6\n");wait(0.5);lcd.cls();val2=0;break;//6
+ case 0x04:
+ T2='9';lcd.printf("9\n");wait(0.5);lcd.cls();val2=0;break;//9
+ case 0x08:
+ wait(0.1);break; //#
+ }
+ break;
+ case 0x08:
+ switch(r){
+ case 0x01:
+ wait(0.1);break;//A
+ case 0x02:
+ wait(0.1);break;//B
+ case 0x04:
+ wait(0.1);break;//C
+ case 0x08:
+ wait(0.1);break; //D
+ } //end switch2
+ break;
+ default:
+ wait(0.001);
+ break;
+ }//end switch1
+ }//end for
+ }//end while val 2
+
+ int val3=1;
+ val3=1;
+ while(val3){
+ for (int i=0; i<4;i++){
+ r=1<<i;
+ switch(c){//switch 1
+ case 0x01:
+ switch(r){
+ case 0x01:
+ T3='1';lcd.printf("1\n");wait(0.5);lcd.cls();val3=0;break;//1
+ case 0x02:
+ T3='4';lcd.printf("4\n");wait(0.5);lcd.cls();val3=0;break;//4
+ case 0x04:
+ T3='7';lcd.printf("7\n");wait(0.5);lcd.cls();val3=0;break;//7
+ case 0x08:
+ wait(0.1);break; //asterisco
+ }
+ break;
+ case 0x02:
+ switch(r){
+ case 0x01:
+ T3='2';lcd.printf("2\n");wait(0.5);lcd.cls();val3=0;break;//2
+ case 0x02:
+ T3='5';lcd.printf("5\n");wait(0.5);lcd.cls();val3=0;break;//5
+ case 0x04:
+ T3='8';lcd.printf("8\n");wait(0.5);lcd.cls();val3=0;break;//8
+ case 0x08:
+ T3='0';lcd.printf("0\n");wait(0.5);lcd.cls();val3=0;break; //0
+ }
+ break;
+ case 0x04:
+ switch(r){
+ case 0x01:
+ T3='3';lcd.printf("3\n");wait(0.5);lcd.cls();val3=0;break;//3
+ case 0x02:
+ T3='6';lcd.printf("6\n");wait(0.5);lcd.cls();val3=0;break;//6
+ case 0x04:
+ T3='9';lcd.printf("9\n");wait(0.5);lcd.cls();val3=0;break;//9
+ case 0x08:
+ wait(0.1);break; //#
+ }
+ break;
+ case 0x08:
+ switch(r){
+ case 0x01:
+ wait(0.1);break;//A
+ case 0x02:
+ wait(0.1);break;//B
+ case 0x04:
+ wait(0.1);break;//C
+ case 0x08:
+ wait(0.1);break; //D
+ } //end switch2
+ break;
+ default:
+ wait(0.001);
+ break;
+ }//end switch1
+ }//end for
+ }//end while val 3
+
+ for(int k=0;k<5;k++){ //adorno
+ lcd.printf("*******\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.2);lcd.cls();
+ }
+
+ lcd.printf(" %c %c %c\n", T1, T2, T3);wait(1);lcd.cls(); //mostrando contraseña
+
+ //int c1=contra[0];int c2=contra[1];int c3=contra[2];
+ if(T1==c1 && T2==c2 && T3==c3){
+ lcd.printf("O\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf("SO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf("ESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf("CESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf("CCESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf("ACCESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" ACCESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" ACCESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" ACCESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" ACCESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" ACCESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" ACCESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" ACCESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" ACCESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" ACCESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" ACCESO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" ACCES\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" ACCE\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" ACC\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" AC\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" A\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" \n");wait(0.2);lcd.cls();
+ motor=1;
+ wait(2);
+ motor=0;
+ }
+ else{
+ lcd.printf("O\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf("DO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf("ADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf("GADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf("EGADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf("NEGADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf("ENEGADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf("DENEGADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DENEGADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DENEGADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DENEGADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DENEGADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DENEGADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DENEGADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DENEGADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DENEGADO\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DENEGAD\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DENEGA\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DENEG\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DENE\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DEN\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" DE\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.001);lcd.cls();
+ lcd.printf(" D\n");wait(0.2);lcd.cls();
+ lcd.printf(" \n");wait(0.2);lcd.cls();
+ NVIC_SystemReset();
+ }
+
+ } //end while (1)
+}//end int
diff -r 000000000000 -r df5d1a705b6d TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Wed Sep 26 18:37:40 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r df5d1a705b6d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Sep 26 18:37:40 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file