Hi..
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
Code
#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);
Serial.begin(9600);
}
void loop() {
String sInterval = String("Intrv :");
sInterval.concat(first_drop_duration);
lcd.setCursor(0,0); // Sets the cursor to col 0 and row 0
lcd.print(sInterval); // Prints value on Potpin1 to LCD
Serial.println(sInterval);
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;
s1.concat(first_drop_duration);
lcd.print(s1);
Serial.print("Input Value KeyPad :");
Serial.println(customKey);
Serial.println(s1);
delay(5000);
}
}