why is my code hanging on the while loop?

#include <Keypad.h>
int Hold = (0);
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
    {'1','2','3'},
    {'4','5','6'},
    {'7','8','9'},
    {'*','0','#'}
};

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

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
char key = keypad.getKey();
void setup(){
    Serial.begin(9600);
    randomSeed(analogRead(0));
    int GameNumber = (0);
}
void loop(){
  int GameNumber = (random (9));
  int Hold = (1);
  Serial.println(GameNumber);
    while (Hold = (1))
       key = keypad.getKey();
          if (key == '2')
          Serial.println("win");
    Hold = (0);
}

My code wont accept the input even though i’m reading it inside the while loop. i cant see whats wrong the keypad works fine it has to be this

  while (Hold = (1))Would you care to explain what you think this line is doing and how ?

While you are at it, please explain (why) (you) (need) (to) (put) (all) (the) (values) (in) (parentheses).

#include <Keypad.h>
int Hold = 0;
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
    {'1','2','3'},
    {'4','5','6'},
    {'7','8','9'},
    {'*','0','#'}
};

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

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
char key = keypad.getKey();
void setup(){
    Serial.begin(9600);
    randomSeed(analogRead(0));
    int GameNumber = 0;
}
void loop(){
  int GameNumber = random (9);
  int Hold = 1;
  Serial.println(GameNumber);
    while (Hold = 1)
       key = keypad.getKey();
          if (key == '2')
          Serial.println("win");
    Hold = (0);
}

Thanks… it still doesn’t work

UKHeliBob:  while (Hold = (1))

Would you care to explain what you think this line is doing and how ?

while the value of hold is equal to one, while will continue to loop until the number two on the keypad is pressed, then after that happens the value hold will change to 0 and that program will start again and generate another random number and wait for you to press two.

Maybe look up the difference between assignment and comparison

  while (Hold == 1)

The suspense was killing me.

-jim lee

jimLee:   while (Hold == 1)

The suspense was killing me.

-jim lee

Or, as OP seems to prefer:

   while(Hold == (1))