Ayuda novato, incapaz de programar algo en pantalla serial 128x64 sparkfun

11 Mar 2014
183
Santa Cruz de Tenerife
Provincia
Santa Cruz de Tenerife
Muy buenas, tengo un arduino mega, pantalla LCD de 128x64 serial )[/URL], reloj tiny RTC.

Quiero hacerme un dimeo con encendido y apagado de dos canales conectados a LDDs.

El problema que me veo es que soy capaz de programar cosillas, pero soy realmente incapaz de poner nada en la pantalla, ni siquiera un hola mundo.

Alguien me recomienda una libreria que me valga y algunos ejemplitos para poder estudiarlos y aprender a usarla.

Muchas gracias!!!
 
11 Mar 2014
183
Santa Cruz de Tenerife
Provincia
Santa Cruz de Tenerife
He conseguido cosillas, poder en hora el reloj y manejar la pantalla por fin con la libreria serialGLCD.h y algun ejemplo que encontre en los foros de sparkfun.




//Código para poner el hora el reloj y visulizarlo
#include <Wire.h>
#include <serialGLCD.h>
#define DS1307_I2C_ADDRESS 0x68
byte second, minute, hour, dayOfWeek;
byte month, year;
byte day;
// 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) );
}
void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte day, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(0);
Wire.write(decToBcd(second));
Wire.write(decToBcd(minute));
Wire.write(decToBcd(hour));
Wire.write(decToBcd(dayOfWeek));
Wire.write(decToBcd(day));
Wire.write(decToBcd(month));
Wire.write(decToBcd(year));
Wire.endTransmission();
}
// Establece la fecha y el tiempo del ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *day,
byte *month,
byte *year)
{
// Resetea el registro puntero
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
*second = bcdToDec(Wire.read() & 0x7f);
*minute = bcdToDec(Wire.read());
*hour = bcdToDec(Wire.read() & 0x3f);
*dayOfWeek = bcdToDec(Wire.read());
*day = bcdToDec(Wire.read());
*month = bcdToDec(Wire.read());
*year = bcdToDec(Wire.read());
}
void setup()
{

Wire.begin();

////////////////////////////////////////////////////////////////////////////////////
//Aqui hay que modificar y poner los valores "actuales" para poner el hora el reloj//
////////////////////////////////////////////////////////////////////////////////////
second = 00;
minute = 35;
hour = 00;
dayOfWeek = 4;
day = 1;
month = 4;
year = 14;
///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
setDateDs1307(second, minute, hour, dayOfWeek, day, month, year);

Serial.begin(115200); //default baudrate of the display, can be changed, consult summoningdark's README that comes with the firmware to change it
delay(1000);


}

serialGLCD lcd; // initialisation



void loop()
{

getDateDs1307(&second, &minute, &hour, &dayOfWeek, &day, &month, &year);
lcd.clearLCD();
lcd.gotoPosition(1,62);
if (day < 10) Serial.print("0");
Serial.print(day, 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);
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);
lcd.gotoPosition(1,54);
Serial.print("Canal 1:");
lcd.gotoPosition(1,46);
Serial.print("Canal 2:");
lcd.gotoPosition(1,38);
Serial.print("Hora inicio: 10:00");
lcd.gotoPosition(1,30);
Serial.print("Hora sol: 14:00");
lcd.gotoPosition(1,22);
Serial.print("Hora apagado: 22:00");

delay(5000);
}

Poner en hora el reloj es gracias al tutorial de McPollo
https://todomarino.com/comunidad/sh...-con-arduino-Parte-2-(Reloj-y-led-de-control)
 
Última edición:
Arriba