Needing help for project

Hello All,

I'm relatively new to programming however I have a problem getting something to work,

Basically I have a Keypad connected to a LCD, I have this so far for one of my voids:

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

This will display a value pressed on the keypad, however I want to then:

  1. Declare this as a variable called "Temp1"
  2. Have a second button pressed and printed to (1,1)
  3. Declare this as a second variable called "Temp2"
  4. Confirmed with keypad press "A"
  5. Decline with keypad press "B"

Thanks,
Elliott.

  1. Declare this as a variable called “Temp1”

Aside from not knowing what “this” is, what’s stopping you?

  1. Have a second button pressed and printed to (1,1)

You are going about this all wrong. The getKey() method is not a blocking function. That is, it does not wait for a key to be pressed.

You need to collect key press data in loop(), whenever it happens, and then call that function to display the key pressed, at the appropriate location.

for one of my voids:

for one of your "functions", void just indicates nothing is returned.

Make a small for:loop that looks for 3 characters within the function. Right now it stops after the 1st one.

PaulS:

  1. Declare this as a variable called "Temp1"

Aside from not knowing what "this" is, what's stopping you?

How would I go about declaring it? do I just:

int Temp1 = getKey()

do I just:

No. Look at the code that you already have that calls the getKey() method.