Use of Keypad to select cases

Hey guys, I'm going to be as clear as possible with this, but if there is more information needed, please just ask.

I'm using an Arduino UNO for a university project, and the only roadblock that I seem to be running into is that I can't seem to program the keypad to select between a few cases.

If the problem is due to not connecting the whole keypad, my question becomes: Is there a way to use only certain parts of the keypad (in my case I only want to use 1 and 2)

There are no errors when this code is run.
I'm not sure what is wrong, I'm not very experienced in programming so most of this code is re purposed from what I found on the internet. I can provide links (usually other forum posts).
I'm using the 4x4 keypad with the ABCD on the side. (no clue the part #)

I'm expecting this code to react to me pushing 1 or 2 and then run one of the two for loops (and then allow another selection if necessary).

Memory usage:
Sketch uses 5326 bytes (16%) of program storage space. Maximum is 32256 bytes.
Global variables use 230 bytes (11%) of dynamic memory, leaving 1818 bytes for local variables. Maximum is 2048 bytes.

I'm cutting this off partway through due to the code afterwards being functional.

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

LiquidCrystal lcd(4, 1, 8, 7, 6, 5);


const byte ROWS = 1; 
const byte COLS = 2; 

char Keys[ROWS][COLS] = {
  {'1', '2'}
};
byte rowPins[ROWS] = {13}; 
byte colPins[COLS] = {12, 3}; 
Keypad myKeypad= Keypad(makeKeymap(Keys), rowPins, colPins, ROWS, COLS);

enum state {hot, cold, neither} current_state = neither;

int buttonState = 0;
int lastButtonState = 0;
int buttonPushCounter = 0;
int buttonState2 = 0;
int lastButtonState2 = 0;
int buttonPushCounter2 = 0;
int sensorPin=0;
//analog pin 0 for temp

void setup()
{
  pinMode(2, INPUT);
  pinMode(9, INPUT);
  lcd.begin(16, 2);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
}

void loop()
{
  char preSet=myKeypad.getKey();
  switch (current_state){
    case hot: 
    for (int i=0; i <=25; i++){
      digitalWrite(10,HIGH);
      delay(1000);
      digitalWrite(10, LOW);
      delay(1000);
    }
    break;
    case cold:
    digitalWrite(11, HIGH);
    delay(1000);
    digitalWrite(11, LOW);
    break;
    case neither:
    break;
  }
  switch (myKeypad.getState()){
    case PRESSED:
    switch(preSet){
      case '1': current_state = hot;
      case '2': current_state = cold;
      case 'NO_KEY': current_state = neither;
    }
    break;
  }

If the problem is due to not connecting the whole keypad

More likely, the problem is not connect the right parts of the keypad.

You have way too much code for someone that is not certain that the keypad is wired correctly. Go back to the keypad examples, and just print out which key is pressed, when one is pressed. If that doesn't work, you do not have the (limited part of) the keypad wired correctly.

Even if the keypad is attached correctly, there are some issues with your code.

      switch (preSet) {
        case '1': current_state = hot;
        case '2': current_state = cold;
        case 'NO_KEY': current_state = neither;
      }

Hint: break;

I would also suggest moving handling of myKeypad to the beginning of loop() and then act on keypresses.

  char preSet = myKeypad.getKey();

When getKey() returns a value, you know a key is pressed. And as long as you only are interrested in state 'PRESSED', there is no need for checking for that, just check the value of preSet.

You say the rest of your 'code is functional', but what happens when 'current_state' is 'hot'?

PaulS:
More likely, the problem is not connect the right parts of the keypad.

You have way too much code for someone that is not certain that the keypad is wired correctly. Go back to the keypad examples, and just print out which key is pressed, when one is pressed. If that doesn't work, you do not have the (limited part of) the keypad wired correctly.

I'm not sure why this is happening, but as soon as I run the code, the serial prints a '1' and doesnt print anything on keypress. With this code I grabbed from online. With the previous code remaining the same.

void setup()
{
  pinMode(2, INPUT);
  pinMode(9, INPUT);
  lcd.begin(16, 2);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  Serial.begin(9600);
}
  

void loop()
{
  char customKey = myKeypad.getKey();
  
  if (customKey){
    Serial.println(customKey);
  }

It seems to be wired correctly, i have the first pin (row 1) connected, pin 5 and 6 (col 1 and 2) connected.

leongjerland:
I would also suggest moving handling of myKeypad to the beginning of loop() and then act on keypresses.

When getKey() returns a value, you know a key is pressed. And as long as you only are interrested in state 'PRESSED', there is no need for checking for that, just check the value of preSet.

You say the rest of your 'code is functional', but what happens when 'current_state' is 'hot'?

I moved the initial part.

So instead of getKey should i be using the event listener? I'm really not sure

And by the rest of the code is functional I mean that everything after what I inserted into my first post works.
I can change the initial value of 'current_state' to 'hot' and it wont run the loop at all. I'm not sure if thats due to it just not working like that or if its an indicator of that part of the code being faulty also.

As a side note: I'm using tinkercad to simulate the program due to not actually having a board to connect. I know thats not your problem, but I'm just putting all information out there just in case.
I write the program in the IDE, verify it, then copy it over to tinkercad with my simulated board to give it a try.

When you get your real hardware, and have the keypad connected per your way of thinking it should be connected, let us know what the code actually does.

Thanks for wasting our time with a tinkercad problem.