Only one button being detected?

Dear Arduino Community,
I am working on a project that uses two buttons (randomButton and resetButton) to control a variable called “days.” When one of these buttons is pressed, they change the value of “days,” and then print the output to the serial monitor. However, I can only get the randomButton to output anything to the serial monitor. resetButton does not print anything when pressed. Does anyone have any ideas? The sketch is attached below.
Thanks, icecats

Time_Lock_Box.ino (1.32 KB)

if (digitalRead(resetButton) == HIGH && locked != false)

Where in that code is locked set to anything other than false? It's not the button part that is stopping this from running.

Here's the code attached above for those who don't want to download:

// Constants won't change
const int randomButton = 3; // Assign pin 3 to the random button
const int resetButton = 4; // Assign pin 4 to the reset button

// Variables will change
unsigned int days = 0; // Positive variable less than 65,535 called "days"
boolean locked = false; // True/false variable called "locked"

void setup()
{
  Serial.begin(9600); // Initiate the serial monitor
  pinMode(randomButton, INPUT);
  pinMode(resetButton, INPUT);
}

void loop()
{

  // If the random button is pressed
  if (digitalRead(randomButton) == HIGH)
  {
    days = random(1, 11); // Generate a random number between 1(inclusive) and 11(exlusive) and store it in variable "days"
    Serial.print("random value "); // Print a label
    Serial.println(days); // Print the value of "days" to the serial monitor
    while (digitalRead(randomButton) == HIGH)
    {
      // This is too prevent the button from registering multiple times
    }
  }

  // If the reset button is pressed and the box has not been locked yet
  if (digitalRead(resetButton) == HIGH && locked != false)
  {
    days = 0;
    Serial.print("reset value"); // Print a label
    Serial.println(days); // Print the value of "days" to the serial monitor
    while (digitalRead(resetButton) == HIGH)
    {
      // This is too prevent the button from registering multiple times
    }
  }
}

Thanks Delta_G. iPad will not read .ino

Thank you Delta_G, I changed the statement to say when locked == false and it works! I found this error a while ago, but only changed it to locked = false (one equals sign). I then must have changed it back to the original. Anyways thank you for pointing out this rather embarrassing mistake. Since you seem to have quite a bit of Arduino experience, can you please also check out my button edge detection (the empty while loop in each if statement). Did I write the edge detection correctly. Thank you for taking the time to help me. Sincerely, icecats

That’s one way to do it, but it locks your program up in that while loop until you release the button.

The IDE comes with an example called State Change. Have a look at that for a better way.