Can Someone tell me why this code doesn't work

void rollDice(void);
void sevenseg(byte);
void pattern(void);

byte die1 = 8;
byte die2 = 8;

byte numbers= {0xF9,0xA4,0xB0,0x99,0x92,0x82,0x80};

void setup() {
pinMode(0,INPUT_PULLUP); // push button

pinMode(1,OUTPUT); // Segment A
pinMode(2,OUTPUT); //Segment B
pinMode(3,OUTPUT); //Segment C
pinMode(4,OUTPUT); //Segment D
pinMode(5,OUTPUT); //Segment E
pinMode(6,OUTPUT); //Segment F
pinMode(7,OUTPUT); //Segment G

pinMode(8, OUTPUT); //Multiplexor

randomSeed(analogRead(0));
}

void loop() {
byte die1 = 8;
byte die2 = 8;

while(digitalRead(0)== LOW)
rollDice();
digitalWrite(8,HIGH);
sevenseg(numbers[die1]);
delay(10);
digitalWrite(8,LOW);
sevenseg(numbers[die2]);
delay(10);

}

void sevenseg(byte die){
byte i; // counter variable
for(i = 0; i < 7; i++){
if(bitRead(numbers[die-1],i)){ //(numbers[die-1],i))
digitalWrite(i+1, HIGH); //i+1, high
}
else
digitalWrite(i+1, LOW);
}
}

void rollDice(void){
sevenseg(8);
while(!digitalRead(0)){
die1 = random(1,7);
die2 = random(1,7);
pattern();
}

}

void pattern(void){
sevenseg(8);
for(byte i=0;i<2;i++){
digitalWrite(8,HIGH);
digitalWrite(1,LOW);
delay(20);
digitalWrite(8, LOW);
digitalWrite(2,HIGH);
delay(20);
digitalWrite(8,HIGH);
digitalWrite(2,LOW);
delay(20);
digitalWrite(8, LOW);
digitalWrite(3,HIGH);
delay(20);
digitalWrite(8,HIGH);
digitalWrite(3,LOW);
delay(20);
digitalWrite(8, LOW);
digitalWrite(4,HIGH);
delay(20);
digitalWrite(8,HIGH);
digitalWrite(4,LOW);
delay(20);
digitalWrite(8, LOW);
digitalWrite(5,HIGH);
delay(20);
digitalWrite(8,HIGH);
digitalWrite(5,LOW);
delay(20);
digitalWrite(8, LOW);
digitalWrite(6,HIGH);
delay(20);
digitalWrite(8,HIGH);
digitalWrite(6,LOW);
delay(20);
}
}

What do you mean "doesn't work"? What does it do or not do?

On what Arduino is it running?

its supposed to roll two dice and get a random number for each die 1-6

running on Arduino uno

And what does it do?

it supposed to generate two random numbers like a dice on two 7 segment LED displays

I'm not asking what it's supposed to do, I'm asking what it is doing.

Pin 1 on an UNO is the TX pin.
Pin 0 is RX pin

its not giving me two random numbers on the LED's

BTW

You have defined global and local die1 and die2 variables.

Always comment the code lines in your sketch.


Show us a good schematic of your proposed circuit. Show us a good image of your ‘actual’ wiring.
Give links to components.


In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

Use the </> icon from the ‘reply menu’ to attach the copied sketch.

its the metro mini