Jjaja

Dependencies:   mbed FXOS8700Q TextLCD

Committer:
thesad
Date:
Thu Jun 11 02:45:08 2020 +0000
Revision:
0:421257dc3042
jejejej caiste

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thesad 0:421257dc3042 1 #include "mbed.h"
thesad 0:421257dc3042 2 #include "C12832.h"
thesad 0:421257dc3042 3
thesad 0:421257dc3042 4
thesad 0:421257dc3042 5 DigitalOut L1(p8);
thesad 0:421257dc3042 6 DigitalOut L2(p9);
thesad 0:421257dc3042 7 DigitalOut L3(p10);
thesad 0:421257dc3042 8 AnalogIn pot(p15);
thesad 0:421257dc3042 9 C12832 lcd(SPI_MOSI, SPI_SCK, SPI_MISO, p8, p11);
thesad 0:421257dc3042 10
thesad 0:421257dc3042 11
thesad 0:421257dc3042 12 //Contadores para cada dígito
thesad 0:421257dc3042 13 int seg1=0; //Variable para contador de unidades de segundo
thesad 0:421257dc3042 14 int seg2=0; //Variable para contador de décimas de segundo
thesad 0:421257dc3042 15 int min1=0; //Variable para contador de unidades de minuto
thesad 0:421257dc3042 16 int min2=0; //Variable para contador de décimas de minuto
thesad 0:421257dc3042 17 int hor1=0; //Variable para contador de unidades de hora
thesad 0:421257dc3042 18 int hor2=0; //Variable para contador de décimas de hora
thesad 0:421257dc3042 19
thesad 0:421257dc3042 20 void reloj(){//Subrutina para generar reloj de 6 segmentos
thesad 0:421257dc3042 21 lcd.locate(21,1);//Posicionamiento de las unidades de segundo
thesad 0:421257dc3042 22 lcd.printf("%i", seg1);
thesad 0:421257dc3042 23 lcd.locate(11,1);//Posicionamiento de las décimas de segundo
thesad 0:421257dc3042 24 lcd.printf("%i",seg2);
thesad 0:421257dc3042 25 lcd.locate(26,1);//Posicionamiento del doble punto
thesad 0:421257dc3042 26 lcd.printf(":");
thesad 0:421257dc3042 27 lcd.locate(42,1);//Posicionamiento de las unidades de minuto
thesad 0:421257dc3042 28 lcd.printf("%i",min1);
thesad 0:421257dc3042 29 lcd.locate(32,1);//Posicionamiento de las décimas de minuto
thesad 0:421257dc3042 30 lcd.printf("%i",min2);
thesad 0:421257dc3042 31 lcd.locate(49,1);//Posicionamiento del punto doble
thesad 0:421257dc3042 32 lcd.printf(":");
thesad 0:421257dc3042 33 lcd.locate(63,1);//Posicionamiento de las unidades de minuto
thesad 0:421257dc3042 34 lcd.printf("%i",hor1);
thesad 0:421257dc3042 35 lcd.locate(53,1);//Posicionamiento de las décimas de minuto
thesad 0:421257dc3042 36 lcd.printf("%i",hor2);
thesad 0:421257dc3042 37 }
thesad 0:421257dc3042 38
thesad 0:421257dc3042 39
thesad 0:421257dc3042 40 int main() {
thesad 0:421257dc3042 41
thesad 0:421257dc3042 42 printf("Proyecto, equipo 3\n");
thesad 0:421257dc3042 43 printf("Contraseña: 8569 \n");
thesad 0:421257dc3042 44 float x;
thesad 0:421257dc3042 45 lcd.cls();
thesad 0:421257dc3042 46 while(1){
thesad 0:421257dc3042 47 x = 5*pot.read();
thesad 0:421257dc3042 48
thesad 0:421257dc3042 49 if(x<3.5){
thesad 0:421257dc3042 50
thesad 0:421257dc3042 51 lcd.cls(); //Limpia el LCD
thesad 0:421257dc3042 52 lcd.locate(15, 15); //Posiciona en columna 2, fila 0)
thesad 0:421257dc3042 53 lcd.printf("Tiempo de inactividad"); //Imprime en LCD "Reloj digital"
thesad 0:421257dc3042 54 lcd.copy_to_lcd();
thesad 0:421257dc3042 55
thesad 0:421257dc3042 56
thesad 0:421257dc3042 57
thesad 0:421257dc3042 58 reloj(); //Llama a subrutina
thesad 0:421257dc3042 59
thesad 0:421257dc3042 60 seg1++; //Inician el primer contador de unidades de segundo
thesad 0:421257dc3042 61 wait(1); //Genera tiempo de un segundo
thesad 0:421257dc3042 62 if (seg1==10){
thesad 0:421257dc3042 63 seg2++;//Contador décimas de segundo
thesad 0:421257dc3042 64 seg1=0;
thesad 0:421257dc3042 65 if (seg2==6){
thesad 0:421257dc3042 66 min1++;//Contador unidades de minuto
thesad 0:421257dc3042 67 seg2=0;
thesad 0:421257dc3042 68 if (min1==10){
thesad 0:421257dc3042 69 min2++;//Contador décimas de minuto
thesad 0:421257dc3042 70 min1=0;
thesad 0:421257dc3042 71 if(min2==6){
thesad 0:421257dc3042 72 hor1++;//Contador unidades de hora
thesad 0:421257dc3042 73 min2=0;
thesad 0:421257dc3042 74 if(hor1==10){
thesad 0:421257dc3042 75 hor2++;//Contador décimas de hora
thesad 0:421257dc3042 76 hor1=0;
thesad 0:421257dc3042 77 if((hor2==2)&&(hor1==4)){/*Cuando el contador llega
thesad 0:421257dc3042 78 a 24hrs, este se reinicia*/
thesad 0:421257dc3042 79 hor2=0;
thesad 0:421257dc3042 80 hor1=0;
thesad 0:421257dc3042 81 }
thesad 0:421257dc3042 82 }
thesad 0:421257dc3042 83 }
thesad 0:421257dc3042 84 }
thesad 0:421257dc3042 85 }
thesad 0:421257dc3042 86 }
thesad 0:421257dc3042 87 }
thesad 0:421257dc3042 88
thesad 0:421257dc3042 89
thesad 0:421257dc3042 90 if(x>=3.5){
thesad 0:421257dc3042 91
thesad 0:421257dc3042 92 int valida = 8569;
thesad 0:421257dc3042 93 int clave;
thesad 0:421257dc3042 94
thesad 0:421257dc3042 95
thesad 0:421257dc3042 96 lcd.cls();
thesad 0:421257dc3042 97 lcd.locate(1,1);
thesad 0:421257dc3042 98 lcd.printf( "Introduzca su clave: ");
thesad 0:421257dc3042 99 scanf("%i", &clave) ;
thesad 0:421257dc3042 100 wait(1);
thesad 0:421257dc3042 101
thesad 0:421257dc3042 102 if(clave != valida) {
thesad 0:421257dc3042 103
thesad 0:421257dc3042 104 lcd.locate(1,15);
thesad 0:421257dc3042 105 lcd.printf("No valida!");
thesad 0:421257dc3042 106 lcd.copy_to_lcd();
thesad 0:421257dc3042 107 L1 = 1;
thesad 0:421257dc3042 108 wait(0.3);
thesad 0:421257dc3042 109 L1 = 0;
thesad 0:421257dc3042 110 wait(0.3);
thesad 0:421257dc3042 111 L1 = 1;
thesad 0:421257dc3042 112 wait(0.3);
thesad 0:421257dc3042 113 L1 = 0;
thesad 0:421257dc3042 114 wait(0.3);
thesad 0:421257dc3042 115 L1 = 1;
thesad 0:421257dc3042 116 wait(0.3);
thesad 0:421257dc3042 117 L1 = 0;
thesad 0:421257dc3042 118 lcd.cls();
thesad 0:421257dc3042 119 clave=0;
thesad 0:421257dc3042 120 }
thesad 0:421257dc3042 121
thesad 0:421257dc3042 122 if (clave == valida){
thesad 0:421257dc3042 123 lcd.locate(1,15);
thesad 0:421257dc3042 124 lcd.printf("Aceptada.");
thesad 0:421257dc3042 125 L2 = 1;
thesad 0:421257dc3042 126 L3 = 1;
thesad 0:421257dc3042 127 wait(0.3);
thesad 0:421257dc3042 128 L2 = 0;
thesad 0:421257dc3042 129 wait(0.3);
thesad 0:421257dc3042 130 L2 = 1;
thesad 0:421257dc3042 131 wait(0.3);
thesad 0:421257dc3042 132 L2 = 0;
thesad 0:421257dc3042 133 wait(0.3);
thesad 0:421257dc3042 134 L2 = 1;
thesad 0:421257dc3042 135 wait(0.3);
thesad 0:421257dc3042 136 L2 = 0;
thesad 0:421257dc3042 137 wait(15);
thesad 0:421257dc3042 138 L3 = 0;
thesad 0:421257dc3042 139
thesad 0:421257dc3042 140 }
thesad 0:421257dc3042 141 if (clave == 0){
thesad 0:421257dc3042 142 lcd.cls();
thesad 0:421257dc3042 143 lcd.locate(1,1);
thesad 0:421257dc3042 144 lcd.printf( "No ha introducido ninguna clave");
thesad 0:421257dc3042 145
thesad 0:421257dc3042 146 }
thesad 0:421257dc3042 147 }
thesad 0:421257dc3042 148 }
thesad 0:421257dc3042 149 }