How can I get a single random number?

Hello, I have just started to use Arduino and I am loving it. I am trying to make a project that rolls a random die, and I'm having trouble getting a single random number and not a million like i am getting now.
any and all help is appreciated, code below.

int randomNum;
void setup() {
// put your setup code here, to run once:

pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
Serial.begin(9600);
Serial.println("test");
i=0;
}

void loop() {
randomNum=random(7);
Serial.println(randomNum);
// put your main code here, to run repeatedly:
//int randomNum=3;

if(randomNum==1)
{
digitalWrite(0, HIGH);
}
else if(randomNum==2)
{
digitalWrite(1, HIGH);
digitalWrite(6, HIGH);
}
else if(randomNum==3)
{
digitalWrite(1,HIGH);
digitalWrite(0,HIGH);
digitalWrite(6,HIGH);
}
else if(randomNum==4)
{
digitalWrite(1,HIGH);
digitalWrite(3,HIGH);
digitalWrite(6, HIGH);
digitalWrite(4, HIGH);
}
else if (randomNum==5)
{
digitalWrite(1,HIGH);
digitalWrite(3,HIGH);
digitalWrite(6, HIGH);
digitalWrite(4, HIGH);
digitalWrite(0,HIGH);

}
else if (randomNum==6)
{
digitalWrite(1,HIGH);
digitalWrite(3,HIGH);
digitalWrite(6, HIGH);
digitalWrite(4, HIGH);
digitalWrite(2, HIGH);
digitalWrite(5, HIGH);
}

}

If you only want it to run once, put the code in setup.
Be aware that you'll always get the same random number.

Call randon only when you want a random number. That presumably will be when some sort of event triggers
your code to do something. The body of loop just needs to be if clauses checking for events and/or timeouts.

You should also take note that random(7) can return any one of the numbers 0, 1, 2, 3, 4, 5, 6. You aren't testing for zero.

Pete

random(1,7)

Delta_G:
I think the thing the OP is missing is the fact that the loop function gets repeated over and over. Since his doesn't take but just a few microseconds to run, that means his loop will run thousands and thousands of times per second. If you just want to slow it down add a delay and see what happens. Then go see the "Blink Without Delay" example to see how to do it even better so it doesn't block the rest of your code.

OP is making the usual mistake of thinking only about the guts of his algorithm and not about how it will be packaged. Typically, you don't want to "roll a die". What you want is "roll a die when a button is pressed", or "roll a die once every 30 seconds when the temperature is above 20℃".

Basically, OP, the guts of your program works - it rolls a die. Move that out into a function:

void loop() {
  roll_the_die();
}

void roll_the_die() {
 randomNum=random(7);
  Serial.println(randomNum);
 
/* etc, etc - all the rest of your dice rolling code goes here */


}

Now, look at your loop() function. It says: "every time I am executed, which will be thousands of time a second, roll the die". What should it say? Write the stuff that handles the conditions under which the die should be rolled, and put that in loop().