LCD display not refreshing


i have a int global variable (first_drop_duration) with default value 0 (zero). This variable will be updated with an input value from keypad.

LCD is always displays “Intrv : 0” (see attached image)

But updated global variable is not getting displayed in LCD, but shows correctly in "Serial Monitor".. please can you help what is wrong here.

ps-this input to be used to control the Solenoid value later.

Output in Serial Monitor

Intrv :0
Input Value KeyPad :4
Input value Variable:400
Intrv :400
Intrv :400


#include <LiquidCrystal.h>
#include <Keypad.h>

int solenoidPin = 4;    //This is the output pin on the Arduino we are using

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7,8,9,10,11,12);

int first_drop_duration = 00;
int interval_delay = 2000;       // variable to store the interval between two set

int potPin1 = A2;
int PotentioValue = 0;

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns

char keys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'#', '0', '*', 'D'}

byte rowPins[ROWS] = {8, 7, 6, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 3, 2,1}; //connect to the column pinouts of the keypad

Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);

void setup() {
  // put your setup code here, to run once:
  pinMode(solenoidPin, OUTPUT);           //Sets the pin as an output

  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  //lcd.print("hello, world!");

  pinMode(potPin1, INPUT);

void loop() {
  String sInterval = String("Intrv :");
  lcd.setCursor(0,0); // Sets the cursor to col 0 and row 0
  lcd.print(sInterval); // Prints value on Potpin1 to LCD
  char customKey = customKeypad.getKey();
  if (customKey) {
    String s1 = String("Input value Variable:");
    first_drop_duration = (int(customKey) - 48);  //as it returns ascii value, subtract it with 48.  
    first_drop_duration = first_drop_duration * 100;

    Serial.print("Input Value KeyPad :");

Can you concat a String and an int as you are doing ?

int first_drop_duration = 00;

Use 0 not 00. Leading zeroes have a special meaning. It doesn't matter here, but it will bite you for anything other than 0.

I notice that some of the keypad pins are the same as the LCD pins. Do you really have them connected to the same pins? How do you expect that to work?

LiquidCrystal lcd(7,8,9,10,11,12);
byte rowPins[ROWS] = {8, 7, 6, 5};

Are 8 and 7 really shared? Not a good idea.

It also says your solenoid is on pin 4:

int solenoidPin = 4;

And it says that pin is being used for the keypad as well.

byte colPins[COLS] = {4, 3, 2,1};

It also shows you using pin 1 for the keypad. You can't have pin 1 if you use Serial since 1 is one of the serial pins.

Do you really have multiple things connected to these pins?