Hi there,
Been reading this forum for a while. Got my arduino and love it.
Got my LCD working. But now want to improve it.
I have 16 chars in my LCD, but I want to display 24... hum.. scroling I thought!
Since the text I wana scroll is in byte variables, I first must convert them in to text, and the add it to a string to scroll in the LCD, Right?
Well it's easier to say than do... Heeelppp Please :S
#include <LCD4Bit_mod.h>
byte second=0;
byte minute=0;
byte hour=0;
byte dayofweek=1;
byte day=1;
byte month=1;
byte year=10;
void setup(){
Serial.begin(19200);
lcd.init();
lcd.clear();
lcd.printIn("***LCD ON***");
delay(200);
}
void loop(){
char* dias [] ={" Domingo"," Segunda"," Terça"," Quarta"," Quinta"," Sexta"," Sábado"};
//day=0; RTC returns days as 0 to 7, Sunday, Monday..etc.
char temp="";
char MESSAGE[24];
sprintf(MESSAGE, "%i:%i %c %i-%i-%i", hour,minute, dias[dayofweek],day,month,year);
// Desired result line below
// char MESSAGE[] = "12:12 Segunda 01-10-2010";
int MESSAGE_LENGTH = sizeof(MESSAGE) - 1;
const int DISPLAY_WIDTH = 15;
int g_nPosition = 0;
int i;
if(g_nPosition < MESSAGE_LENGTH - DISPLAY_WIDTH)
{
for(i=0; i<DISPLAY_WIDTH; i++)
{
lcd.cursorTo(i, 0);
lcd.printIn(MESSAGE[g_nPosition + i]);
}
}
else
{
int nChars = MESSAGE_LENGTH - g_nPosition;
for(i=0; i<nChars; i++)
{
lcd.cursorTo(i, 0);
lcd.printIn(MESSAGE[g_nPosition + i]);
}
for(i=0; i<(DISPLAY_WIDTH - nChars); i++)
{
lcd.cursorTo(i, 0);
lcd.printIn(MESSAGE[g_nPosition + i]);
}
}
g_nPosition++;
if(g_nPosition >= MESSAGE_LENGTH)
{
g_nPosition = 0;
}
delay(500);
}
For now waiting to get home after work and see where we stand.. eehehhe