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.
Fork of 4_1bueno by
Revision 1:dec5ec0fa2dc, committed 2018-10-17
- Comitter:
- aldomarez
- Date:
- Wed Oct 17 20:28:26 2018 +0000
- Parent:
- 0:df5d1a705b6d
- Commit message:
- ticker and LCD
Changed in this revision
41prueba.cpp | Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r df5d1a705b6d -r dec5ec0fa2dc 41prueba.cpp --- a/41prueba.cpp Wed Sep 26 18:37:40 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,314 +0,0 @@ -/*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 df5d1a705b6d -r dec5ec0fa2dc main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 17 20:28:26 2018 +0000 @@ -0,0 +1,31 @@ +#include "mbed.h" +#include "TextLCD.h" + +TextLCD lcd(D4,D5,A2,A3,A4,A5); // rs, e, d4-d7 +AnalogIn val1(A0); +AnalogIn val2(A1); +DigitalOut motor(D6); +Ticker flipper; +float v1; +float v2; +float lima = 25.0f; +float limb = 18.0f; + +void flip() { + v1 = val1; + v2 = val2; + v1 = v1 * 33.3f; + v2 = v2 * 33.3f; +} +int main() { + flipper.attach(&flip, 0.4); + while(1) { + lcd.printf("V1= %f C\nV2= %f C", v1,v2); + wait(0.2); + lcd.cls(); + if(v1>=lima && v2<=limb) { + motor = 1; + } + else motor = 0; + } +} \ No newline at end of file