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:4ff2d6652d22, committed 2020-06-15
- Comitter:
- karlaivon
- Date:
- Mon Jun 15 23:49:07 2020 +0000
- Commit message:
- Proyecto final, equipo 3
Changed in this revision
diff -r 000000000000 -r 4ff2d6652d22 FXOS8700Q.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FXOS8700Q.lib Mon Jun 15 23:49:07 2020 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/Freescale/code/FXOS8700Q/#aee7dea904e2
diff -r 000000000000 -r 4ff2d6652d22 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jun 15 23:49:07 2020 +0000 @@ -0,0 +1,218 @@ +#include "mbed.h" +#include "C12832.h" + + +DigitalOut L1(p8); +DigitalOut L2(p9); +DigitalOut L3(p10); +AnalogIn pot(p15); +PwmOut speaker(p21); +C12832 lcd(SPI_MOSI, SPI_SCK, SPI_MISO, p8, p11); + + +//Contadores para cada dígito +int seg1=0; //Variable para contador de unidades de segundo +int seg2=0; //Variable para contador de décimas de segundo +int min1=0; //Variable para contador de unidades de minuto +int min2=0; //Variable para contador de décimas de minuto +int hor1=0; //Variable para contador de unidades de hora +int hor2=0; //Variable para contador de décimas de hora + +void reloj(){//Subrutina para generar reloj de 6 segmentos + lcd.locate(21,1);//Posicionamiento de las unidades de hora + lcd.printf("%i", hor1); + lcd.locate(11,1);//Posicionamiento de las décimas de hora + lcd.printf("%i",hor2); + lcd.locate(26,1);//Posicionamiento del doble punto + lcd.printf(":"); + lcd.locate(42,1);//Posicionamiento de las unidades de minuto + lcd.printf("%i",min1); + lcd.locate(32,1);//Posicionamiento de las décimas de minuto + lcd.printf("%i",min2); + lcd.locate(49,1);//Posicionamiento del punto doble + lcd.printf(":"); + lcd.locate(63,1);//Posicionamiento de las unidades de segundo + lcd.printf("%i",seg1); + lcd.locate(53,1);//Posicionamiento de las décimas de segundo + lcd.printf("%i",seg2); +} + + void play_tone(float frequency, float volume, int interval, int rest) { + speaker.period(1.0 / frequency); + speaker = volume; + wait(interval); + speaker = 0.0; + wait(rest); +} +int main() { + + printf("Proyecto final, equipo 3\n"); + printf("Código: 8569 \n"); +float x; + lcd.cls(); + while(1){ + x = 5*pot.read(); + + if(x<3.5){ + + lcd.cls(); //Limpia el LCD + lcd.locate(15, 15); //Posiciona en columna 2, fila 0) + lcd.printf("Tiempo de inactividad"); //Imprime en LCD "Reloj digital" + lcd.copy_to_lcd(); + + + + reloj(); //Llama a subrutina + + seg1++; //Inician el primer contador de unidades de segundo + wait(1); //Genera tiempo de un segundo + if (seg1==10){ + seg2++;//Contador 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(min2==6){ + hor1++;//Contador unidades de hora + min2=0; + if(hor1==10){ + hor2++;//Contador décimas de hora + hor1=0; + if((hor2==2)&&(hor1==4)){/*Cuando el contador llega + a 24hrs, este se reinicia*/ + hor2=0; + hor1=0; + } + } + } + } + } + } + } + + + if(x>=3.5){ + + int valida = 8569; + int clave; + int intentos; + + + lcd.cls(); + lcd.locate(1,1); + lcd.printf( "Introduzca su clave: "); + wait(1); + scanf("%i", &clave) ; + wait(1); + + if(clave != valida) { + lcd.cls(); + lcd.locate(1,1); + lcd.printf("No valida!"); + lcd.copy_to_lcd(); + + play_tone(125.0, 0.5, 1, 2); + play_tone(125.0, 0.5, 1, 2); + L1 = 1; + wait(0.3); + L1 = 0; + wait(0.3); + L1 = 1; + wait(0.3); + L1 = 0; + wait(0.3); + L1 = 1; + wait(0.3); + L1 = 0; + lcd.cls(); + clave=0; + intentos++; + if(intentos==3){ + int p=0; + for (p; p<10; p++){ + lcd.cls(); + lcd.locate(1,1); + lcd.printf("Sistema bloqueado %d", p); + lcd.copy_to_lcd(); + play_tone(125.0, 0.5, 1, 0.5); + play_tone(800.0, 0.5, 1, 0.5); + play_tone(125.0, 0.5, 1, 0.5); + } + } + } + + if (clave == valida){ + lcd.cls(); + lcd.locate(1,1); + lcd.printf("Aceptada."); + lcd.locate(1,15); + lcd.printf("Abriendo compuerta..."); + play_tone(800.0, 0.5, 0.7, 1); + L2 = 1; + L3 = 1; + wait(0.3); + L2 = 0; + wait(0.3); + L2 = 1; + wait(0.3); + L2 = 0; + wait(0.3); + L2 = 1; + wait(0.3); + L2 = 0; + wait(15); + L3 = 0; + Abrir: + lcd.cls(); + lcd.locate(20,1); + lcd.printf("Compuerta abierta"); + lcd.locate(1,10); + lcd.printf( "Introduzca su clave"); + lcd.locate(1,20); + lcd.printf( "para cerrar"); + wait(1); + scanf("%i", &clave) ; + wait(1); + if (clave == valida){ + lcd.cls(); + lcd.locate(1,1); + lcd.printf("Aceptada."); + lcd.locate(1,15); + lcd.printf("Cerrando..."); + play_tone(800.0, 0.5, 0.7, 1); + L2 = 1; + L3 = 1; + wait(0.3); + L2 = 0; + wait(0.3); + L2 = 1; + wait(0.3); + L2 = 0; + wait(0.3); + L2 = 1; + wait(0.3); + L2 = 0; + wait(15); + L3 = 0; + lcd.cls(); + lcd.locate(20,5); + lcd.printf("Compuerta cerrada"); + wait(3); + } + else{ + lcd.cls(); + lcd.locate(10,1); + lcd.printf("Incorrecto Vuelva"); + lcd.locate(10,10); + lcd.printf(" a intentarlo"); + wait(3); + goto Abrir; + } + } + + } +} +} \ No newline at end of file
diff -r 000000000000 -r 4ff2d6652d22 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jun 15 23:49:07 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file