Arduino Random Dice roller and Dice Selector

/*LCD1602
You should now see your LCD1602 display the result of rolling a d20

Created by L. M.

2018.9.17*/

#include <LiquidCrystal.h>// include the library code


char array1[] = "Side yy!"; //the string to print on the LCD
char array2[] = "You rolled a xx!"; //the string to print on the LCD
int tim = 50;  //the value of delay time
int num = 0;
int randNumber = 0;
int keyIn = 2;
int switchDie = 3;
int number = 1;
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(4, 6, 10, 11, 12, 13);

void setup()
{
  lcd.begin(16, 1);  // set up the LCD's number of columns and rows:
  pinMode(keyIn, INPUT_PULLUP);
  pinMode(switchDie, INPUT_PULLUP);
  Serial.begin(9600);
  
  Serial.print("button press");
    
    lcd.clear();  //Clears the LCD screen and positions the cursor in the upper-left corner.
    lcd.setCursor(15, 1); // set the cursor to column 15, line 1

    for (int positionCounter1 = 0; positionCounter1 < 8; positionCounter1++)
    {
      /*printf(positionCounter1);*/
      lcd.scrollDisplayLeft();  //Scrolls the contents of the display one space to the left.
      //lcd.print(array1[positionCounter1]);  // Print a message to the LCD.
      delay(tim);  //wait for 50 ms
    }
}


void loop()
{
  int stat = digitalRead(keyIn);  //store value read from keyIn
  int die  = digitalRead(switchDie);
  
  if(stat == LOW)  // check if the pushbutton is pressed
  {
    num = 1;
  }
  else
  {
    num = 0;
  }
  //Serial.println(num);  // print the num on serial monitor
  Serial.print("button press");
  if (die == LOW)
  {
    number = 1;
    if((number ++) == 6)
    {
      //number = 1;
    }
  }
  
  //lcd.print(array1[position counter1])
  //lcd.print(04)
  if(num == 1)  //when pushbutton is pressed
  {
    switch (number)
    {
      case 1: //d4
        randNumber = random(1,5); //store random between 1 and 4
        lcd.clear();
        lcd.setCursor(15, 1);
        lcd.scrollDisplayLeft();
        lcd.print("Side 04!");
        delay(tim);
        
        break;
      case 2: //d6
        randNumber = random(1,7); //store random between 1 and 6
        lcd.clear();
        lcd.setCursor(15, 1);
        lcd.scrollDisplayLeft();
        lcd.print("Side 06!");
        delay(tim);
        
        break;
      case 3: //d8
        randNumber = random(1,9); //store random between 1 and 8
        lcd.clear();
        lcd.setCursor(15, 1);
        lcd.scrollDisplayLeft();
        lcd.print("Side 08!");
        delay(tim);
        
        break;
      case 4: //d10
        randNumber = random(1,11); //store random between 1 and 10
        lcd.clear();
        lcd.setCursor(15, 1);
        lcd.scrollDisplayLeft();
        lcd.print("Side 10!");
        delay(tim);
        
        break;
      case 5: //d12
        randNumber = random(1,13); //store random between 1 and 12
        lcd.clear();
        lcd.setCursor(15, 1);
        lcd.scrollDisplayLeft();
        lcd.print("Side 12!");
        delay(tim);
        
        break;
      case 6: //20
        randNumber = random(1,21); //store random between 1 and 21
        lcd.clear();
        lcd.setCursor(15, 1);
        lcd.scrollDisplayLeft();
        lcd.print("Side 20!");
        delay(tim);
        
        break;
      default: //cant get here
        randNumber = 42;
        break;
    }
     
    array2[13] = (randNumber / 10) + 0x30;
    array2[14] = (randNumber % 10) + 0x30;
    
    lcd.clear();  //Clears the LCD screen and positions the cursor in the upper-left corner.
    lcd.setCursor(15, 1); // set the cursor to column 15, line 1

    for (int positionCounter2 = 0; positionCounter2 < 16; positionCounter2++)
    {
      /*printf(positionCounter2);*/
      lcd.scrollDisplayLeft();  //Scrolls the contents of the display one space to the left.
      lcd.print(array2[positionCounter2]);  // Print a message to the LCD.
      delay(tim);  //wait for 250 ms
    }
  }
}

The goal of this program is to do two things.

The button tied to the #2 pin will roll a random number for a selected dice.
The button tied to the #3 pin will allow you to select a dice. Every button push is supposed to select the next button up.

e.g. D4 push D6 push D8 , D10 , D12 , D20

So far, rolling a dice works well, unfortunately it is stuck on the D4.
I have been looking online before posting here but I can't seem to find a solution to this.

Help very much appreciated!

Note: The code does not throw any errors at this time.

So far, rolling a dice works well, unfortunately it is stuck on the D4.

I'm sure you know what this means, but I haven't a clue what is stuck on D4, or why.

    number = 1;
    if((number ++) == 6)
    {
      //number = 1;
    }

2 does not equal 6, so the statement will never be true. Not that it matters, since nothing happens if it is true and nothing happens if it is false.

Do you REALLY mean to set number to 1 every time die is LOW?

That code was an experiment at one point, but as you pointed out it does nothing.

Stuck on D4, is that it does not switch states from the first case. (Just a bit down in the code, case 1 is the 4 sided die or D4)

What i want it to do, is, every time the button is pushed its state switches to low which will give it a value of 1.
If it has a value of one, perceed to the next case.

What i want it to do, is, every time the button is pushed its state switches to low which will give it a value of 1.
If it has a value of one, perceed to the next case.

You've used one pronoun, it, 4 times. I can't imagine that the pronoun refers to the same noun in all 4 uses.

Try again, without using the pronoun "it" in your reply.

You really should look at the state change detection example. It seems to me that you want to count the number of times one switch becomes pressed, and use that count when the other switch becomes pressed.

That is correct.

"What I want the code to do: Every time the button is pressed, the buttons state becomes LOW, giving it a value of 1. If the button has a value of 1, due to state LOW, go to the next case."

The second button will use the count of the current case.

After looking up StateChangeDetection, that is exactly what I want each button press to do.

A questing regarding SCD.
In order to give each button count a value, would I assign a value to each incremental value such as the case value that I have, or is there a more optimal method of providing a value to the # of state changes?

I apologize for the unclear question, I am a new to this and experimenting around and not familiar with many of the commands.
Appreciate the help though!