Taller de Arduino

  • Iniciador del tema Iniciador del tema jmcadsl
  • Fecha de inicio Fecha de inicio
Estado
Cerrado para nuevas respuestas.
Necesitas tener la libreria SLCD en la carpeta /libraries creo recordar que un par o tres posts despues del código que has copiado hay un zip de jmcadsl donde posteó las librerias que el había utilizado, las copias todas dentro y a compilar.
 
Hola para todos:

Estoy empezando con el Arduino.

Tengo montado el reloj rtc ds1307, ademas de pantalla serial.

Intento empezar con el codigo usando lo que en esta pagina tenemos pero no logro que funcione. Me da errores de compilado.

Alguien con caridad me podría ayudar por favor.

Estoy muy agradecido y por favor no paréis.

Mi placa Arduino Uno. El LCd el de Sparkfun serial16x2.

Un abrazo

El error me da esto.


sketch_nov29a.cpp:186:24: error: SLCD.h: No such file or directory
sketch_nov29a.cpp: In function 'void loop()':
sketch_nov29a:163: error: expected primary-expression before '/' token
sketch_nov29a:163: error: 'Pausa' was not declared in this scope
sketch_nov29a:163: error: expected `;' before 'durante'
sketch_nov29a.cpp: At global scope:
sketch_nov29a:171: error: 'SLCD' does not name a type
sketch_nov29a.cpp: In function 'byte decToBcd(byte)':
sketch_nov29a:173: error: redefinition of 'byte decToBcd(byte)'
sketch_nov29a:29: error: 'byte decToBcd(byte)' previously defined here
sketch_nov29a.cpp: In function 'byte bcdToDec(byte)':
sketch_nov29a:177: error: redefinition of 'byte bcdToDec(byte)'
sketch_nov29a:35: error: 'byte bcdToDec(byte)' previously defined here
sketch_nov29a.cpp: In function 'void setup()':
sketch_nov29a:184: error: redefinition of 'void setup()'
sketch_nov29a:91: error: 'void setup()' previously defined here
sketch_nov29a:187: error: 'lcd' was not declared in this scope
sketch_nov29a.cpp: In function 'void Lcdini()':
sketch_nov29a:197: error: 'lcd' was not declared in this scope
sketch_nov29a.cpp: In function 'void lcdoff()':
sketch_nov29a:203: error: 'lcd' was not declared in this scope
sketch_nov29a.cpp: In function 'void FadeLcd()':
sketch_nov29a:212: error: 'lcd' was not declared in this scope
sketch_nov29a:216: error: 'lcd' was not declared in this scope
sketch_nov29a.cpp: In function 'void loop()':
sketch_nov29a:235: error: redefinition of 'void loop()'
sketch_nov29a:112: error: 'void loop()' previously defined here
sketch_nov29a.cpp: In function 'void getDateDs1307(byte*, byte*, byte*, byte*, byte*, byte*, byte*)':
sketch_nov29a:254: error: redefinition of 'void getDateDs1307(byte*, byte*, byte*, byte*, byte*, byte*, byte*)'
sketch_nov29a:71: error: 'void getDateDs1307(byte*, byte*, byte*, byte*, byte*, byte*, byte*)' previously defined here
sketch_nov29a.cpp: In function 'void InfoLcd()':
sketch_nov29a:280: error: 'lcd' was not declared in this scope

//
// CONTROLADOR ACUARIO V2.0

//FASE 1 - RELOJ

//////////////////////////////////////////////////////////////////////////7

#include <Wire.h> // Esta es la libreria de comunicacion I2C
#define DS1307_I2C_ADDRESS 0x68

// Convierte números normales decimales a BCD (binario decimal codificado)
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}

// Convierte BCD (binario decimal codificado) a números normales decimales
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}

// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock

void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(decToBcd(second));
Wire.send(decToBcd(minute));
Wire.send(decToBcd(hour));
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.endTransmission();
}

// Establece la fecha y la hora del reloj
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Resetea el registro puntero
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();

Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

// Alguno de estos necesitan enmascarar porque ciertos bits son bits de control

*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f);
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}

void setup()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
Serial.begin(9600);


/*
// la primera vez debemos poner en hora, active esta parte y luego vuelva a quitarla
second = 00;
minute = 15;
hour = 21;
dayOfWeek = 6;
dayOfMonth = 19;
month = 9;
year = 9;

setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
*/
}

void loop()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

Serial.print("20");
if (year < 10) Serial.print("0");
Serial.print(year, DEC);
Serial.print("/");
if (month < 10) Serial.print("0");
Serial.print(month, DEC);
Serial.print("/");
if (dayOfMonth < 10) Serial.print("0");
Serial.print(dayOfMonth, DEC);
Serial.print(" ");
if (hour < 10) Serial.print("0");
Serial.print(hour, DEC);
Serial.print(":");
if (minute < 10) Serial.print("0");
Serial.print(minute, DEC);
Serial.print(":");
if (second < 10) Serial.print("0");
Serial.print(second, DEC);
Serial.print(" Dia de la semana:");
Serial.println(dayOfWeek, DEC);
switch (dayOfWeek)
{
case 1:
Serial.println(" Lunes");
break;
case 2:
Serial.println(" Martes");
break;
case 3:
Serial.println(" Miercoles");
break;
case 4:
Serial.println(" Jueves");
break;
case 5:
Serial.println(" Viernes");
break;
case 6:
Serial.println(" Sabado");
break;
case 7:
Serial.println(" Domingo");
break;
}

delay(1000); /Pausa durante 1 segundo
}
 
hola
infinity si la pantalla que tienes puesta es la mia... no es serial. te conteste en la foto que me comentaste.
has probado algunos de los archivos que te envie?
 
Última edición:
Hola Karagos¡¡¡¡

De momento tengo la tuya puesta con botonera. Ademas compre el otro dia la serial 16x2 de Brico..
Con el código que me has enviado funciona genial, pero no logro poner el RTC en hora.
El Arduino cada dia me gusta mas y este foro me parece impresionante macho.
Usando la pantalla serial lo que me pasa es que me faltan las librerias.

Entiendo que las tengo que meter en Arduino / libraries. creo yo no?.
Un abrazo desde los Madriles y gracias por vuestras respuestas.
 
para ponerlo en hora primero cargas el código que has puesto arriba, pero tienes que borrar los simbolos /* y tambien */ que estan omitiendo el trozo de codigo que queda entre ellos. Ahi cambias y pones la hora que tu quieres: lo cargas. luego vuelves a poner esos /* y */ en su sitio de modo que se anula el trozo de código donde se cambia la hora y lo vuelves a cargar. lo deberias tener puesto en hora.
cuidado que al final falta una barra, justo antes de donde dice /pausa de 1 segundo
hay que poner otra barra y anular eso así: //pausa de 1 segundo
 
hola pues yo el arduino lo tengo parado esperando el lcd... te lo llevaste y me cortastes las alas.
nos vemos.
referente al reloj ya te ha respondido el compañero bbq.
 
Como esto no acaba de organizarse, me he permitido la licencia de abrir el post de mi arduino a continuacion de este, ya que esta pasando el tiempo y empiezo a olvidarme de muchas cosas.
Os invido a que vayais haciendo lo mismo (o mejor) para que así podamos dar mejor servicio a todos los que aterrizan ahora.
He reservado los cuatro primeros posts para ir haciendo los cambios y demás. A ver si en unos días dejo todo bien documentadito para futuras consultas.

Os dejo el link, pero está en nuestros talleres, y si respetamos el título pues así estaran todos anidados.
https://todomarino.com/comunidad/temas/66722/
 
hola me parece excelente, podrias en los primeros post colgar las preguntas mas importantes que vallan surgiendo con sus respuestas. voy a visitarlo.
 
Lo voy a ir haciendo poco a poco, a ver que tal queda, es una buena opcion esa de poner las preguntas mas relevantes.
De momento, voy colocando donde he hecho yo las compras para ir a tiro echo.
Se me complica la vida con el tema de la pantalla, pero intentaré explicarlo lo mejor que pueda.

Gracias karagos, os invito a que hagais lo mismo.
 
Hola Makinasss¡¡

Pues reloj puesto en hora. Active tal y como me indicáis la sección de código para puesta en hora. Perfecto. Ahora tengo otro problema.
No me muestra la hora por el display. Tengo ahora montado el Serial.

Karanos: Que display tienes pensado cogerte.

Que puede pasar compañeros?..

Muchas muchas gracias.
 
Me respondo a mi mismo. Me voy enterando.

No he incluido la parte para que la info aparezca en el display.

Lo he hecho pero me falkta la libreria SLCD.H.

Jmcadsl nos ofreció dicha librería pero cuando abro el archivo la que me aparece se llama. SLCD.cpp.o.

Es el primer error de compilado que me da después de añadir el codigo.

Abrazos.
 
Hola Foro,

Tengo el reloj puesto en hora, pero me da un nuevo error de compilado. Solucionada la inclusión de la libreria SLCD.h, este es el nuevo error.

Adjunto codigo para el estudio por parte de las mentes pensantes.

//
// CONTROLADOR ACUARIO V2.0 de jmcadsl

//FASE 1 - RELOJ

///////////////////////////////////////////////////////////////////////////

#include <Wire.h> // Esta es la libreria de comunicacion I2C
#define DS1307_I2C_ADDRESS 0x68

// Convierte números normales decimales a BCD (binario decimal codificado)
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}

// Convierte BCD (binario decimal codificado) a números normales decimales
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}

// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock

void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(decToBcd(second));
Wire.send(decToBcd(minute));
Wire.send(decToBcd(hour));
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.endTransmission();
}

// Establece la fecha y la hora del reloj
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Resetea el registro puntero
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();

Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

// Alguno de estos necesitan enmascarar porque ciertos bits son bits de control

*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f);
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}

void setup()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
Serial.begin(9600);


/*
// la primera vez debemos poner en hora, active esta parte y luego vuelva a quitarla
second = 00;
minute = 51;
hour = 20;
dayOfWeek = 2;
dayOfMonth = 30;
month = 11;
year = 10;

setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
*/
}

void loop()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

Serial.print("20");
if (year < 10) Serial.print("0");
Serial.print(year, DEC);
Serial.print("/");
if (month < 10) Serial.print("0");
Serial.print(month, DEC);
Serial.print("/");
if (dayOfMonth < 10) Serial.print("0");
Serial.print(dayOfMonth, DEC);
Serial.print(" ");
if (hour < 10) Serial.print("0");
Serial.print(hour, DEC);
Serial.print(":");
if (minute < 10) Serial.print("0");
Serial.print(minute, DEC);
Serial.print(":");
if (second < 10) Serial.print("0");
Serial.print(second, DEC);
Serial.print(" Dia de la semana:");
Serial.println(dayOfWeek, DEC);
switch (dayOfWeek)
{
case 1:
Serial.println(" Lunes");
break;
case 2:
Serial.println(" Martes");
break;
case 3:
Serial.println(" Miercoles");
break;
case 4:
Serial.println(" Jueves");
break;
case 5:
Serial.println(" Viernes");
break;
case 6:
Serial.println(" Sabado");
break;
case 7:
Serial.println(" Domingo");
break;
}

delay(1000); //Pausa durante 1 segundo
}

////////////////////////////////////// FASE 2 INCLUSION RELOJ EN DISPLAY ///////////////////////////////////

#include <Wire.h>
#define DS1307_I2C_ADDRESS 0x68
#include <SLCD.h> //LCD
#define numRows 2 //LCD filas
#define numCols 16 //LCD columnas
SLCD lcd = SLCD(numRows, numCols); //LCD

byte decToBcd(byte val)//RELOJ
{
return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;//RELOJ

void setup()
{
Wire.begin(); //RELOJ
lcd.init(); //LCD
Serial.begin(9600); //LCD
}


//FUNCIONES SECUNDARIAS

//Iniciar LCD
void Lcdini ()
{
lcd.displayOn();
lcd.clear();
}

void lcdoff()
{
lcd.displayOff();
lcd.brightness(0);
}

// borra pantalla con fade
void FadeLcd()
{

for (char i=99; i>=4; i -= 5) {
lcd.brightness(i);
delay(50);
}

lcd.clear();

for (char i=0; i<100; i += 5) {
lcd.brightness(i);
delay(50);
}
}


// Pausa 3 segundos
void p ()
{
delay (3000);
}




//BUCLE PRINCIPAL
void loop ()
{
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); // LEEMOS LA HORA
InfoLcd(); //Informacion cada hora en pantalla lcd

}




// FUNCIONES PRINCIPALES

// Establece la fecha y el tiempo del ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Resetea el registro puntero
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();

Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

// Alguno de estos necesitan enmascarar porque ciertos bits son bits de control

*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}


// INFORMACION EN PANTALLA LCD
void InfoLcd ()
{
//Nombre proyecto
Lcdini();
lcd.print("L&S NANO-REEF", 0, 2);
lcd.print("VER 2.0", 1, 4);

p();
FadeLcd(); // borra pantalla con fade

// ahora para mostrar fecha y hora
p();//pausa 3segundos

lcd.print("Hora:",0,1);
if (hour < 10) Serial.print("0");
Serial.print(hour, DEC);
Serial.print(":");
if (minute < 10) Serial.print("0");
Serial.print(minute, DEC);
Serial.print(":");
if (second < 10) Serial.print("0");
Serial.print(second, DEC);

switch (dayOfWeek)
{
case 1:
lcd.print("Lun , ",1,0);
break;
case 2:
lcd.print("Mar , ",1,0);
break;
case 3:
lcd.print("Mie , ",1,0);
break;
case 4:
lcd.print("Jue , ",1,0);
break;
case 5:
lcd.print("Vie , ",1,0);
break;
case 6:
lcd.print("Sab , ",1,0);
break;
case 7:
lcd.print("Dom , ",1,0);
break;
}
Serial.print(dayOfMonth, DEC);
Serial.print("/");
if (month < 10) Serial.print("0");
Serial.print(month, DEC);
Serial.print("/");
Serial.print("20");
if (year < 10) Serial.print("0");
Serial.print(year, DEC);

p();
FadeLcd(); // borra pantalla con fade
lcdoff();
}

Y el error de compilado es este señores:

RELOJ_CORRECTO.cpp: In function 'byte decToBcd(byte)':
RELOJ_CORRECTO:175: error: redefinition of 'byte decToBcd(byte)'
RELOJ_CORRECTO:29: error: 'byte decToBcd(byte)' previously defined here
RELOJ_CORRECTO.cpp: In function 'byte bcdToDec(byte)':
RELOJ_CORRECTO:179: error: redefinition of 'byte bcdToDec(byte)'
RELOJ_CORRECTO:35: error: 'byte bcdToDec(byte)' previously defined here
RELOJ_CORRECTO.cpp: In function 'void setup()':
RELOJ_CORRECTO:186: error: redefinition of 'void setup()'
RELOJ_CORRECTO:91: error: 'void setup()' previously defined here
RELOJ_CORRECTO.cpp: In function 'void loop()':
RELOJ_CORRECTO:237: error: redefinition of 'void loop()'
RELOJ_CORRECTO:112: error: 'void loop()' previously defined here
RELOJ_CORRECTO.cpp: In function 'void getDateDs1307(byte*, byte*, byte*, byte*, byte*, byte*, byte*)':
RELOJ_CORRECTO:256: error: redefinition of 'void getDateDs1307(byte*, byte*, byte*, byte*, byte*, byte*, byte*)'
RELOJ_CORRECTO:71: error: 'void getDateDs1307(byte*, byte*, byte*, byte*, byte*, byte*, byte*)' previously defined here


Abrazos mil para todos. Que puede pasar. Entiendo que me dice creo yo que defina correctamente:

void getDateDs1307(byte*, byte*, byte*, byte*, byte*, byte*, byte*)'.

Un abrazo.
 
Infinity acabo de compilar este código y a mi no me da error, te pongo lo que he compilado correctamente:

Creo que se lo que te pasa.... estas utilizando el mismo codigo para hacer pruebas y estas repitiendo funciones. Eso no se puede hacer, no pueden haber dos funciones que se llamen igual.

Prueba el codigo que te adjunto y verás como funciona correctamente. Es mejor hacer las pruebas aparte.

#include <Wire.h>
#define DS1307_I2C_ADDRESS 0x68
#include <SLCD.h> //LCD
#define numRows 2 //LCD filas
#define numCols 16 //LCD columnas
SLCD lcd = SLCD(numRows, numCols); //LCD

byte decToBcd(byte val)//RELOJ
{
return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;//RELOJ

void setup()
{
Wire.begin(); //RELOJ
lcd.init(); //LCD
Serial.begin(9600); //LCD
}


//FUNCIONES SECUNDARIAS

//Iniciar LCD
void Lcdini ()
{
lcd.displayOn();
lcd.clear();
}

void lcdoff()
{
lcd.displayOff();
lcd.brightness(0);
}

// borra pantalla con fade
void FadeLcd()
{

for (char i=99; i>=4; i -= 5) {
lcd.brightness(i);
delay(50);
}

lcd.clear();

for (char i=0; i<100; i += 5) {
lcd.brightness(i);
delay(50);
}
}


// Pausa 3 segundos
void p ()
{
delay (3000);
}




//BUCLE PRINCIPAL
void loop ()
{
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); // LEEMOS LA HORA
InfoLcd(); //Informacion cada hora en pantalla lcd

}




// FUNCIONES PRINCIPALES

// Establece la fecha y el tiempo del ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Resetea el registro puntero
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();

Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

// Alguno de estos necesitan enmascarar porque ciertos bits son bits de control

*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}


// INFORMACION EN PANTALLA LCD
void InfoLcd ()
{
//Nombre proyecto
Lcdini();
lcd.print("L&S NANO-REEF", 0, 2);
lcd.print("VER 2.0", 1, 4);

p();
FadeLcd(); // borra pantalla con fade

// ahora para mostrar fecha y hora
p();//pausa 3segundos

lcd.print("Hora:",0,1);
if (hour < 10) Serial.print("0");
Serial.print(hour, DEC);
Serial.print(":");
if (minute < 10) Serial.print("0");
Serial.print(minute, DEC);
Serial.print(":");
if (second < 10) Serial.print("0");
Serial.print(second, DEC);

switch (dayOfWeek)
{
case 1:
lcd.print("Lun , ",1,0);
break;
case 2:
lcd.print("Mar , ",1,0);
break;
case 3:
lcd.print("Mie , ",1,0);
break;
case 4:
lcd.print("Jue , ",1,0);
break;
case 5:
lcd.print("Vie , ",1,0);
break;
case 6:
lcd.print("Sab , ",1,0);
break;
case 7:
lcd.print("Dom , ",1,0);
break;
}
Serial.print(dayOfMonth, DEC);
Serial.print("/");
if (month < 10) Serial.print("0");
Serial.print(month, DEC);
Serial.print("/");
Serial.print("20");
if (year < 10) Serial.print("0");
Serial.print(year, DEC);

p();
FadeLcd(); // borra pantalla con fade
lcdoff();
}
 
Última edición:
Hola Jmerino.

El codigo funciona. Una pregunta.

¿ Por que los cambios de pantalla de L&s nano reef a la hora son como a saltos?.

Luego entiendo que el display debería de mostrar también el día, con por ejemplo Jue. Creo que eso le indicamos en la ultima parte del programa.
No me aparece.

Espero no ser un plasta con tanta consulta.

Un abrazo.
 
Lo de los saltos que comentas, pues si no te explicas mejor......jejeje

Según el codigo deberia.... cuando se enciende, se muestra ls nano reef y despues de 3 segundos la hora y fecha y 3 segundos mas....es un bucle.
Prueba a quitar el lcdoff() y el fadelcd()......¿que pantalla tienes? tambien puede ser que no sea 100% compatible con la libreria slcd.
 
hola he encontrado esta fuente dimmeable para led.

como lo veis

Tiene una pinta estupenda...de 8 a 14 leds....y dimeable por voltaje de 0-5v asi que con un pin del Arduino lo dimeas.....ójala la hubiera encontrado hace unos meses jejejeje

Infinity en un rato te subo un código para que te muestre la hora sin saltos...
 
Hola Jmerino.

El codigo funciona. Una pregunta.

¿ Por que los cambios de pantalla de L&s nano reef a la hora son como a saltos?.

Luego entiendo que el display debería de mostrar también el día, con por ejemplo Jue. Creo que eso le indicamos en la ultima parte del programa.
No me aparece.

Espero no ser un plasta con tanta consulta.

Un abrazo.

Prueba con este otro codigo:
Código:
#include <Wire.h>
#define DS1307_I2C_ADDRESS 0x68
#include <SLCD.h> //LCD
#define numRows 2 //LCD filas
#define numCols 16 //LCD columnas
SLCD lcd = SLCD(numRows, numCols); //LCD

byte decToBcd(byte val)//RELOJ
{
return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;//RELOJ

void setup()
{
Wire.begin(); //RELOJ
lcd.init(); //LCD
Serial.begin(9600); //LCD
}


//BUCLE PRINCIPAL
void loop ()
{
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); // LEEMOS LA HORA
InfoLcd(); //Informacion cada hora en pantalla lcd

}

// FUNCIONES PRINCIPALES

// Establece la fecha y el tiempo del ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Resetea el registro puntero
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();

Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

// Alguno de estos necesitan enmascarar porque ciertos bits son bits de control

*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}


// INFORMACION EN PANTALLA LCD
void InfoLcd ()
{
//Nombre proyecto
lcd.print("INFINITY-REEF", 0, 2);
lcd.print("VER 2.0", 1, 4);
delay(2000);
lcd.clear(); // borra pantalla
// ahora para mostrar fecha y hora
lcd.print("Hora:",0,1);
if (hour < 10) Serial.print("0");
Serial.print(hour, DEC);
Serial.print(":");
if (minute < 10) Serial.print("0");
Serial.print(minute, DEC);
Serial.print(":");
if (second < 10) Serial.print("0");
Serial.print(second, DEC);

switch (dayOfWeek)
{
case 1:
lcd.print("Lun , ",1,0);
break;
case 2:
lcd.print("Mar , ",1,0);
break;
case 3:
lcd.print("Mie , ",1,0);
break;
case 4:
lcd.print("Jue , ",1,0);
break;
case 5:
lcd.print("Vie , ",1,0);
break;
case 6:
lcd.print("Sab , ",1,0);
break;
case 7:
lcd.print("Dom , ",1,0);
break;
}
Serial.print(dayOfMonth, DEC);
Serial.print("/");
if (month < 10) Serial.print("0");
Serial.print(month, DEC);
Serial.print("/");
Serial.print("20");
if (year < 10) Serial.print("0");
Serial.print(year, DEC);
}
 
Estado
Cerrado para nuevas respuestas.
Atrás
Arriba