lcd blink particular index variable

dear all. I am trying to blink particular character with their index. For example hello world . I wanted to blink o continuesly .i tried to impliment blink program but it doesnt worked. Any simple code to blink. I tried like this first print character with delay andthen with space and delay, so it didnt worked

Post you sketch in code tags.

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // Turn off the blinking cursor:
lcd.setCursor(4,0);
  lcd.print("0");
  lcd.noBlink();
  delay(300);
   // Turn on the blinking cursor:
  lcd.print(" ");
  lcd.blink();
  delay(300);
}
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // Turn off the cursor:
lcd.setCursor(4,0);
  lcd.print("0");
  lcd.noCursor();
  delay(500);
   // Turn on the cursor:
 lcd.print(" ");
  lcd.cursor();
  delay(500);
}

Try this. Not a delay() in sight because I presume that the program will need to do other things and not be blocked.

  lcd.setCursor(0, 0);
  lcd.print("Hello World");
}

void loop()
{
  if (millis() - startedFlash > interval)
  {
    if (charToPrint == ' ')
    {
      charToPrint = 'o'; 
    }
    else
    {
      charToPrint = ' '; 
    }
    startedFlash = millis();
    lcd.setCursor(4, 0);
    lcd.print(charToPrint); 
  }
}

Obviously you need to set up the variables appropriately but this is the loop that does the time checking and flashes the character. There is a neater way to do it that I can think of but this one is very obvious as to how it works.

i tried with above code but i dont how to declare getchar.
I have below code

#include <LiquidCrystal.h>LiquidCrystal lcd(12, 11, 7, 6, 5, 4);int Blink_pos[6][2]={                      {5,0},                      {8,0},                      {11,0},                      {5,1},                      {8,1},                      {11,1}                        };                          enum _Screen_edit_item{ EDIT_DAY, EDIT_MONTH, EDIT_YEAR, EDIT_HOUR, EDIT_MINUTE, EDIT_SEC} ;typedef enum _Screen_edit_item EDIT_SCREEN_ITEM;static int local_day=1;static int local_month=3;static int local_year=2014;int local_s=12;static int local_h=23;static int local_m=1;void setup(){   lcd.begin(16,2);  lcd.clear(); }  void loop() {   Blink_LCD(); }   void Blink_LCD(){  int j=0;for(int 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("    ");}

You're five posts off forum god status.
Is it too much to ask that you post properly indented code?

I am not going to reply to this thread until your current code is posted properly.

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
int Blink_pos[6][2]={
  {
    5,0  }
  ,
  {
    8,0  }
  ,
  {
    11,0  }
  ,
  { 
    5,1  }
  ,
  { 
    8,1  } 
  , 
  {
    11,1  }                          
}; 
enum _Screen_edit_item
{ 
  EDIT_DAY,
  EDIT_MONTH,
  EDIT_YEAR, 
  EDIT_HOUR,
  EDIT_MINUTE, 
  EDIT_SEC
};
typedef enum _Screen_edit_item EDIT_SCREEN_ITEM;
static int local_day=1;
static int local_month=3;
static int local_year=2014;
int local_s=12;
static int local_h=23;
static int local_m=1;
void setup(){ 
  lcd.begin(16,2); 
  lcd.clear(); 
} 

void loop()
{   
  Blink_LCD(); 
}  
void Blink_LCD(){ 
  int j=0;
  for(int 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("    ");
}

So, what is it supposed to do and what does it really do ?
Where does getchar come into it as the variable does not appear in my program or yours.

charToPrint declaration error. this code posted above not working. SO i written code where i blink the cursor of date time format

void loop()
{
  if (millis() - startedFlash > interval)
  {
    if (charToPrint == ' ')
    {
      charToPrint = 'o'; 
    }
    else
    {
      charToPrint = ' '; 
    }
    startedFlash = millis();
    lcd.setCursor(4, 0);
    lcd.print(charToPrint); 
  }
}

In my code example charToPrint was declared as a global char but you could declare it at the start of the loop() function as that is the only place that it is used.

I did not post all of the declaration and setup stuff because I have a different LCD and did not want to confuse things further but here is the whole program for my system

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x27 
#define BACKLIGHT_PIN 3

LiquidCrystal_I2C lcd(I2C_ADDR);  //NOTE library changed by BB to hard code pin numbers

unsigned long startedFlash;
unsigned long interval = 500;
char charToPrint = ' ';

void setup()
{ 
  lcd.begin (16,2);
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.clear(); 
  lcd.print("Hello World");
} 

void loop()
{
  if (millis() - startedFlash > interval)
  {
    if (charToPrint == ' ')
    {
      charToPrint = 'o'; 
    }
    else
    {
      charToPrint = ' '; 
    }
    startedFlash = millis();
    lcd.setCursor(4, 0);
    lcd.print(charToPrint); 
  }
}

Is there is simple way to blink other than above method

That depends what you mean by simple. You can avoid checking which character is currently showing using an array, but you might not regard that as simple.

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x27 
#define BACKLIGHT_PIN 3

LiquidCrystal_I2C lcd(I2C_ADDR);  //NOTE library changed by BB to hard code pin numbers

unsigned long startedFlash;
unsigned long interval = 500;
char charsToShow[] = {'o', ' '};
int counter = 0;

void setup()
{ 
  lcd.begin (16,2);
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.clear(); 
  lcd.print("Hello World");
} 

void loop()
{
  if (millis() - startedFlash > interval)
  {
    lcd.setCursor(4, 0);
    lcd.print(charsToShow[(counter++) % 2]); 
    startedFlash = millis();
  }
}

Bear in mind that most of the code is to do with setting up the LCD.

A quick note about my code above. counter should be declared as an unsigned int otherwise the index to the array is not correct when the int goes negative.

Here i found if i change day and month>10 position being shifted

#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  }
  ,
  {
    6,1  }
  ,
  {
    9,1  }
  ,
  {
    11,1  }
};

void Blink_LCD()
{
  int j=0;
 /* 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); goto LABEL;
      break;
    case EDIT_MONTH:
      lcd.print(local_month); goto LABEL; 
      break;
    case EDIT_YEAR:
      lcd.print(local_year); goto LABEL; 
      break;
    case EDIT_HOUR:
      lcd.print(local_h);  goto LABEL;
      break;
    case EDIT_MINUTE:
      lcd.print(local_m); goto LABEL; 
      break;
    case EDIT_SEC:
      lcd.print(local_s);  goto LABEL;
      break;
 
    }
LABEL: lcd.setCursor(Blink_pos[j][0],Blink_pos[j][1]);
      lcd.print("_");
      delay(300);
 // } 

   
    //lcd.noCursor();
    
 // }  

}

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("    ");
}

AMPS - can you please explain what the Blink_LCD() function is supposed to do ?

Why all the (any ?) gotos ? The switch/case should take care of itself and only execute the case where the switch variable is true. The breaks prevent other cases being executed.

I wanted to flicker the Variable in switch cases. Assume I am editing parameter date . I should know date i am editing. So The Blink_LCD(); will be replaced with Blink_LCD(int variable); variable will be position and particular variable to be blink. when it enter loop goes to switch case print the variable then It will execute GOTO statement to print "_". I didn't any other process of doing it.

What about the technique I used in my code in a previous post using millis() ? You must keep the code responsive if you expect the user to enter values and using delay() will slow down input and make it impossible to use.

So, to edit a value take a copy of it, say the month, and use millis() to alternately show the value and a blank or other character. Whilst this is going on accept user input to increment/decrement the value and display it flashing. When the user decides to accept the input copy it to the original variable and display (no flashing) it before exiting that part of the program.

In summary. Display the digit until it is time not to then change it to another character. Display that until it is time not to then display the digit again. Use millis() timing so that you can accept user input whilst flashing the digit.