Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://pastebin.com/9fEnxkgr
- 30/06/2020
- char fecha[]={"200630"}; //AAMMDD
- char hora[]={"0959"}; //
- IncrementarFecha(); //Incrementa en un día, la variable fecha
- bool transmitir_hora=0;
- loop()
- {
- ActualizarHora(); //Se encarga de mantener actualizada la hora
- TransmisionSerie();
- RecepcionSerie();
- ActualizaDisplay();
- SupervisaMenu();
- ActualizarMenu();
- CtrlAlarma();
- }
- voir ActualizarMenu(void)
- {
- static unsigned char opcion_ant=-1;
- //Sigue en el menu
- //se cambió de opción
- if(opcion != opcion_)
- switch(opcion)
- {
- }
- opcion_ant=opcion;
- }
- #define ADC_PIN A5
- #define LEER_ADC AnalogRead(ADC_PIN)
- void SupervisaADC(void)
- {
- adc=LEER_ADC; //adc va de 0 a 1023
- opcion=DeterminarPosicion(adc);
- if(opcion==opcion_ant) return;
- }
- DeterminarPosicion(unsigned int valor)
- {
- if(valor < 250) return(OPCION_1); //0-25%
- if(valor < 500) return(OPCION_2); //25-50%
- if(valor < 750) return(OPCION_3); //50-75%
- return(OPCION_4); //75-100%
- }
- void RecepcionSerie(void)
- {
- if(!Serial.available()) return;
- if(!se_recibio_encabezado)
- {
- dato=Serial.read();
- if(dato!='#') return;
- se_recibio_encabezado=1;
- return;
- }
- //#Actualiza--> Activar Alarma
- //#FL
- //#FA0923
- dato=Serial.read();
- switch(dato)
- {
- case 'F':
- case 'A': armar=1; se_recibio_encabezado=0; break;
- }
- }
- void TransmisionSerie(void)
- {
- if(tramisitir_hora)
- {
- transmitir_hora=0;
- Serial.print(hora);
- }
- }
- void ActualizarHora(void) //Actualiza la variable hora
- {
- //Si no pasaron 60 segundos, salir
- if(millis() - millis_ini < 60000) return;
- millis_ini=millis();
- imprimir_hora=1;
- if(hora[3]<'9')
- {
- hora[3]++;
- return;
- }
- //las unidades de los minutos es 9
- hora[3]='0';
- if(hora[2]<'5')
- {
- hora[2]++; //Decenas de los minutos
- return;
- }
- hora[2]=0;
- //Incrementar la hora
- //...
- //Cuando llegue al final del día
- IncrementarFecha();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement