Dear all,
I have simple code over here. Here i am trying to blink right most character position so in edit mode to understand which character being editing.
Problem facing:
1)Assume my date is 5/3/2014 , In below program i am saying if date/month between 0-10 then 0 in position else print date/month as it is.
a)If date is 5: it printing 05 while blink function called the 0 is replaced with 5 and again going to 0.
2)In below program i am blinking cursor position. I wanted to blink the character but they are declared as integer.SO question here is how to blink date .
if my date is 5/3/2014 . i wanted to blink 5 , if position switched to month blink month
#include <LiquidCrystal.h>
#include <avr/wdt.h>
static int local_day=5;
static int local_month=3;
static int local_year=2014;
int local_s=10;
static int local_h=3;
static int local_m=2;
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
void setup()
{
Serial.begin(9600);
wdt_enable(WDTO_8S);
lcd.begin(16,2);
lcd.clear();
}
void loop()
{
Blink_LCD();
}
enum _Screen_edit_item
{
EDIT_DAY,
EDIT_MONTH,
EDIT_YEAR,
EDIT_HOUR,
EDIT_MINUTE,
EDIT_SEC
}
;
typedef enum _Screen_edit_item EDIT_SCREEN_ITEM;
int Blink_pos[6][2]={
{
6,0 }
,
{
9,0 }
,
{
11,0 }
,
{
5,1 }
,
{
8,1 }
,
{
11,1 }
};
void Blink_LCD()
{
int j;
for( j=0; j<6;j++)
{
digitalClockDisplay();
lcd.setCursor(Blink_pos[j][0],Blink_pos[j][1]);//
Serial.print(Blink_pos[j][0]);
Serial.print(" ");
Serial.println(Blink_pos[j][1]);
lcd.cursor();
delay(300);
switch(j)
{
case EDIT_DAY:
lcd.print(local_day);
break;
case EDIT_MONTH:
lcd.print(local_month);
break;
case EDIT_YEAR:
lcd.print(local_year);
break;
case EDIT_HOUR:
lcd.print(local_h);
break;
case EDIT_MINUTE:
lcd.print(local_m);
break;
case EDIT_SEC:
lcd.print(local_s);
break;
}
lcd.noCursor();
delay(300);
}
}
void digitalClockDisplay()
{
// Serial.print(local_s);
//lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Date:");
if((local_day>0) &&(local_day<10) )
{
lcd.print("0");
lcd.print(local_day);
}
else
{
lcd.print(local_day);
}
lcd.print("/");
if((local_month>0) &&(local_month<10) )
{
lcd.print("0");
lcd.print(local_month);
}
else
{
lcd.print("0");
lcd.print(local_month);
}
lcd.print("/");
lcd.print(local_year);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("Time:");
if((local_h>0) &&(local_h<10) )
{
lcd.print("0");
lcd.print(local_h);
}
else
{
lcd.print(local_h);
}
lcd.print(":");
if((local_m>0) &&(local_m<10) )
{
lcd.print("0");
lcd.print(local_m);
}
else
{
lcd.print(local_m);
}
lcd.print(":");
if((local_s>0) &&(local_s<10) )
{
lcd.print("0");
lcd.print(local_s);
}
else
{
lcd.print(local_s);
}
lcd.print(" ");
}