Keypad and LCD help

Hello everyone,

I've gone brain dead and its late :(,

I am using my LCD as an interface for my project where I want to key in a temperaure using a 16 key membrane pad,
so far this is what I've got:

void TemperatureScreen()
{
  char Temp1 = keypad.getKey();
  
  lcd.setCursor(0,0);
  lcd.print("Temperature?");
  lcd.setCursor(2,1);
  lcd.print((char)223);
  lcd.setCursor(3,1);
  lcd.print("C");
  lcd.setCursor(0,1);
 
   if (int(Temp1) != 0) 
   {
    lcd.print(Temp1);
}

I have tried many different ways to do the next step however I can't do it, I want to then set lcd.setCursor(1,1); and follow the same:

if (int(Temp2) != 0) 
   {
    lcd.print(Temp2);

for my next value. However I want to be able to refer back to these values later on in the program how would I do this?

Thanks in advance :slight_smile:

Without a schematic of how the keypad is connected I don't know how we would be able to help you. If you are using an lcd keypad shield with lcd and keypad integrated then you are supposed to state that in your first post along with a schematic or link to the vendor site where you bought it so we can look up the schematic.

You need to post your full code.

sorry the whole code so far is:

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

const byte rows = 4;
const byte cols = 4;

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

byte rowPins[rows] = {22, 23, 24, 25};
byte colPins[cols] = {26 ,27 ,28 ,29};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8,9,4,5,6,7);

void setup() {
   // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);    
  lcd.setCursor(0,0);
  lcd.print("Welcome,");
  delay(3000);
  ClearScreen();
  lcd.setCursor(0,0);
  lcd.print("To my");
  lcd.setCursor(0,1);
  lcd.print("Project 2014");
  delay(3000);
  ClearScreen();
  lcd.setCursor(0,0);
  lcd.print("Let's begin");
  lcd.setCursor(0,1);
  delay(3000);
  ClearScreen();
  
}

void loop()
{
 TemperatureScreen(); 

}

void ClearScreen()
{
  lcd.setCursor(0,0);
  lcd.print("                    ");
  lcd.setCursor(0,1);
  lcd.print("                    ");
}

void TemperatureScreen()
{
  char Temp1 = keypad.getKey();
  
  lcd.setCursor(0,0);
  lcd.print("Temperature?");
  lcd.setCursor(2,1);
  lcd.print((char)223);
  lcd.setCursor(3,1);
  lcd.print("C");
  lcd.setCursor(0,1);
 
   if (int(Temp1) != 0) 
   {
    lcd.print(Temp1);
}
void VolumeScreen()
{
  lcd.setCursor(0,0);
  lcd.print("Volume?");
  lcd.setCursor(2,1);
  lcd.print("L");

}

void ConfirmationScreen()
{
}

and my setup so far is:

See now I want to be able to type to variables into (0,1) and (1,1), followed by pressing the A button to confirm or B to cancel, but to be able to use these variables later on in the code is this possible?

Yes it's possible but what are those variables supposed to do? And are you looking to keep them later in the sketch or every time you turn on the arduino?

Thanks for the reply,
I would like the variables which are typed using the keypad to stay as they are until the end of the program/restart, this will happen for both temperature and volume, as I want to refer back and use them later on when sensing temperature because once it hits the temperature typed it will open a valve

Use two global variables, currentTemp and currentVolume. When you enter a value on the keypad, you then update the global variable.

Thanks for the reply again, however that is the problem in having is getting the key pressed and the values to a global variable and displaying them on the lcd I can get one key on the lcd but when I press another it changes the first key on the lcd but I've scrapped that program and started again with this one

The code you posted won't even compile. Why did you post code that won't compile?

PaulS:
The code you posted won't even compile. Why did you post code that won't compile?

Someone asked me to post what I had so far and it's unfinished so it obviously won't compile