Beruflich Dokumente
Kultur Dokumente
* Author
: Hugo Gutierrez Salazar
*
* Release
: 2.9
*
* Soft.Date
: April 8-15th, 2014
*
* Fecha Nuevo Release : March 18th, 2015
*
* Comments
: Include date and buttons setting for
*
*
hours,minutes and seconds.
*
* Hardware Used : - Arduino Uno R-3 module
*
*
- Display LCD Arduino Compatible (LCD 16x2) *
*
- Display (Hitachi HD44780 driver).
*
*******************************************************************
* 18-MAR-2015 : Al cambiar de 31 de Enero, pasaba a 32 de Enero *
* FIX compartido
: Salvador Olmos (Puebla , Mexico)
*
*
y Hugo Gutierrez (Santiago, Chile)
*
*******************************************************************
* 18-MAR-2015 : NO cambia a 29 de Febrero en Ao Bisiesto (2020) *
* FIX
: Hugo Gutierrez (Santiago, Chile)
*
* Language Version : English.
*
******************************************************************/
// Include Liquid Crystal library
#include <LiquidCrystal.h>
#include <stdio.h>
// Initialize library with interface pin numbers
// Each LCD Display can use his how numbers.
LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
// Global variable definitions.
int horas = 0;
int minutos = 0;
int segundos = 1;
// Settings to add date
char ST_DIA[] ="LUMAMIJUVISADO";
char ST_NOM_MES[] ="ENEFEBMARABRMAYJUNJULAGOSEPOCTNOVDIC";
char MES[]
char DIA[]
= "XXX";
= "XX";
= 1;
int N_MES
= 1;
int i
; // Variable to contain day number
int j
= 1; // Variable to contain month number
int
int
int
int
int
ANO
= 2015;
Dia
= 1;
lcd_key = 0;
adc_key_in = 0;
ajuste
= 0; // 1 : Dia : LU ...DO
// 2 : Dia : 1....31
// 3 : Mes : ENE ...DIC
// 4 : AO : 2014 ....
// 5 : HORA : 0 .. 23
// 6 : Minutos : 0 .. 59
}
void loop() {
// Iniciate seconds count.
segundos++;
delay(1000);
// Assign maximum number of days in the month
MAX_DIAS_MES = ST_MES[j-1];
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(1,0);
lcd.print(DIA); /* Dia de la semana LU .. DO */
lcd.setCursor(3,0);
lcd.print("-");
lcd.setCursor(4,0);
if ( Dia < 10 )
lcd.print("0");
lcd.print(Dia); /* Dia del mes 1 .. 31
*/
lcd.setCursor(6,0);
lcd.print("/");
lcd.setCursor(7,0);
lcd.print(MES); /* Mes ...ENE ... DIC
*/
lcd.setCursor(10,0);
lcd.print("/");
lcd.setCursor(11,0);
lcd.print(ANO); /* Ao
*/
lcd.setCursor(15,0);
lcd.print(" ");
// When count overflow 59 seconds, it must increment a minute.
if (segundos > 59 ){
minutos++;
segundos=0;
}
// When count overflow 59 minutes, it must increment an hour
if (minutos > 59 ){
horas++;
minutos = 0;
}
lcd.print("0");
}
lcd.print(horas);
lcd.print(":");
if (minutos < 10){
lcd.print("0");
}
lcd.print(minutos);
lcd.print(":");
if (segundos < 10){
lcd.print("0");
}
lcd.print(segundos);
lcd.print(" ");
// Verify if a button is being pressed
// to set date and time.
lcd_key=read_LCD_buttons();
switch(lcd_key)
{
case btnSELECT: //Set Variable to change
{
lcd.setCursor(0, 0); /* Linea 1 */
lcd.print("Setea
");
ajuste++;
lcd.setCursor(0, 1); /* Linea 2 */
if (ajuste == 1){
lcd.print("Dia : Lu .. Do ");
}
if (ajuste == 2) {
lcd.print("Dia : 01 .. 31 ");
}
if (ajuste == 3) {
lcd.print("Mes : ENE .. DIC");
}
if (ajuste == 4) {
lcd.print("Ano : 2015 ... ");
}
if (ajuste == 5) {
lcd.print("Hora : 00..23 ");
}
if (ajuste == 6) {
lcd.print("Minutos: 00..59 ");
}
if (ajuste > 6 ) {
ajuste = 1;
}
delay(1000);
break;
}
case btnUP: // Count Increment
{
lcd.setCursor(0,0);
lcd.print(" Seteando ");
if (ajuste == 1){
N_DIA++;
if (N_DIA > 7){
N_DIA = 1;
}
// Calculates the day of the week
i=N_DIA;
strncpy(DIA,&ST_DIA[(i-1)*2],2);
DIA[2]='\0';
lcd.setCursor(0,1);
lcd.print("Dia :
lcd.setCursor(6,1);
lcd.print(DIA);
}
if (ajuste == 2){
Dia++;
if (Dia > 31){
Dia = 1;
}
lcd.setCursor(0,1);
lcd.print("Dia :
lcd.setCursor(6,1);
lcd.print(Dia);
");
");
}
if (ajuste == 3){
N_MES++;
if (N_MES > 12){
N_MES = 1;
}
if (N_MES == 2 && Dia > 29)
Dia = 28;
");
");
}
if (ajuste == 5){
horas++;
if (horas > 23)
horas = 0;
lcd.setCursor(0, 1);
lcd.print ("Horas : ");
lcd.setCursor(8, 1);
if (horas < 10)
lcd.print("0");
lcd.print(horas);
lcd.print(" ");
}
if (ajuste == 6 ){
minutos++;
if (minutos > 59 )
minutos = 0;
lcd.setCursor(0, 1);
lcd.print ("Minutos :
lcd.setCursor(9, 1);
if (minutos < 10)
lcd.print("0");
lcd.print(minutos);
}
");
break;
}
case btnDOWN: // Count decrement
{
lcd.setCursor(0,0);
lcd.print(" Seteando ");
if (ajuste == 1){
N_DIA--;
if (N_DIA < 1){
N_DIA = 7;
}
// Calculates the day of the week
i=N_DIA;
strncpy(DIA,&ST_DIA[(i-1)*2],2);
strncat(DIA,'\0',1);
lcd.setCursor(0,1);
lcd.print("Dia :
lcd.setCursor(6,1);
lcd.print(DIA);
");
}
if (ajuste == 2){
Dia--;
if (Dia < 1){
Dia = 31;
}
lcd.setCursor(0,1);
lcd.print("Dia :
lcd.setCursor(6,1);
lcd.print(Dia);
");
}
if (ajuste == 3){
N_MES--;
if (N_MES < 1){
N_MES = 12;
}
// Calculates the name of the month
j = N_MES;
strncpy(MES,&ST_NOM_MES[(j-1)*3],3);
strncat(MES,'\0',1);
lcd.setCursor(0,1);
lcd.print("Mes :
lcd.setCursor(6,1);
lcd.print(MES);
}
if (ajuste == 4){
ANO--;
");
");
}
if (ajuste == 5){
horas--;
if (horas < 0)
horas = 23;
lcd.setCursor(0, 1);
lcd.print ("Horas :
lcd.setCursor(8, 1);
if (horas < 10)
lcd.print("0");
lcd.print(horas);
}
if (ajuste == 6 ){
minutos--;
if (minutos < 0 )
minutos = 59;
lcd.setCursor(0, 1);
lcd.print ("Minutos :
lcd.setCursor(9, 1);
if (minutos < 10)
lcd.print("0");
lcd.print(minutos);
}
break;
}
case btnNONE:
{
break;
}
} /* Switch end */
} /* loop() end */
");
");