Simple, but not geting there yet - Text strings
hi there,
been reading forum while. got arduino , love it.
got lcd working. want improve it.
i have 16 chars in lcd, want display 24... hum.. scroling thought!
since text wana scroll in byte variables, first must convert them in text, , add string scroll in lcd, right?
well it's easier do...
heeelppp please :s
for waiting home after work , see stand.. eehehhe
been reading forum while. got arduino , love it.
got lcd working. want improve it.
i have 16 chars in lcd, want display 24... hum.. scroling thought!
since text wana scroll in byte variables, first must convert them in text, , add string scroll in lcd, right?
well it's easier do...
heeelppp please :scode: [select]
#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 0 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 waiting home after work , see stand.. eehehhe

Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Simple, but not geting there yet - Text strings
arduino
Comments
Post a Comment