LEDs lighting up properly only sometimes, not every time

I am trying to create a two dice arduino project with an accelerometer where you jiggle or turn the breadboard and two sets of leds (in the shape of dice) light up two different numbers. I've got it working... some of the time. Sometimes both sets light up different numbers and other times only one lights up. They alternate back and forth for which one lights up, too, so it's not a problem with just one set of leds. I can't figure out what I'm doing wrong. Can someone look at my code and give me any suggestions?

//Led pins
const int xPin = 2;     // X output of the accelerometer
const int yPin = 3;     // Y output of the accelerometer
int led8 = 8;
int pinLeds1 = 10;
int pinLeds2 = 9;
int pinLeds3 = 7;
int pinLeds4 = 8;
int pinLeds1a = 11;
int pinLeds2a = 12;
int pinLeds3a = 4;
int pinLeds4a = 5;
//Button pin don't need this
int buttonPin = 6;
int buttonState;
//Ran will be randomized from 1 to 6
long ran;
long ran2;
//Time is the time of delay
int time = 2000;

void setup ()
{
  //Set the pins of the leds as Output
  pinMode (pinLeds1, OUTPUT);
  pinMode (pinLeds2, OUTPUT);
  pinMode (pinLeds3, OUTPUT);
  pinMode (pinLeds4, OUTPUT);
  pinMode (pinLeds1a, OUTPUT);
  pinMode (pinLeds2a, OUTPUT);
  pinMode (pinLeds3a, OUTPUT);
  pinMode (pinLeds4a, OUTPUT);
  
  //This code line is necessary for a correct random
  randomSeed(analogRead(0));
 
  // initialize the pins connected to the accelerometer
  // as inputs:
  pinMode(xPin, INPUT);
  pinMode(yPin, INPUT);
}


void loop()
{

  // variables to read the pulse widths:
  int pulseX, pulseY;
  // variables to contain the resulting accelerations
  int accelerationX, accelerationY;

  // read pulse from x- and y-axes:
  pulseX = pulseIn(xPin, HIGH);
  pulseY = pulseIn(yPin, HIGH);

  // convert the pulse width into acceleration
  // accelerationX and accelerationY are in milli-g's:
  // earth's gravity is 1000 milli-g's, or 1g.
  accelerationX = ((pulseX / 10) - 500) * 8;
  accelerationY = ((pulseY / 10) - 500) * 8;

 

  if (accelerationX > 100)
  {
    ran = random(7);
    ran2 = random(7);
    //Number 1
    if (ran == 1){
      digitalWrite (pinLeds4, HIGH);
      
    }
    //Number 2
    if (ran == 2){
      digitalWrite (pinLeds1, HIGH);
      
    }
    //Number 3
    if (ran == 3){
      digitalWrite (pinLeds3, HIGH);
      digitalWrite (pinLeds4, HIGH);
      
    }
    //Number 4
    if (ran == 4){
      digitalWrite (pinLeds1, HIGH);
      digitalWrite (pinLeds3, HIGH);
      
    }
    //Number 5
    if (ran == 5){
      digitalWrite (pinLeds1, HIGH);
      digitalWrite (pinLeds3, HIGH);
      digitalWrite (pinLeds4, HIGH);
      
   }
   //Number 6
   if (ran == 6){
      digitalWrite (pinLeds1, HIGH);
      digitalWrite (pinLeds2, HIGH);
      digitalWrite (pinLeds3, HIGH);
      
   }

   
    //Number 1
    if (ran2 == 1){
      digitalWrite (pinLeds4a, HIGH);
     
    }
    //Number 2
    if (ran2 == 2){
      digitalWrite (pinLeds1a, HIGH);
      
    }
    //Number 3
    if (ran2 == 3){
      digitalWrite (pinLeds3a, HIGH);
      digitalWrite (pinLeds4a, HIGH);
      
    }
    //Number 4
    if (ran2 == 4){
      digitalWrite (pinLeds1a, HIGH);
      digitalWrite (pinLeds3a, HIGH);
     
    }
    //Number 5
    if (ran2 == 5){
      digitalWrite (pinLeds1a, HIGH);
      digitalWrite (pinLeds3a, HIGH);
      digitalWrite (pinLeds4a, HIGH);
      
   }
   //Number 6
   if (ran2 == 6){
      digitalWrite (pinLeds1a, HIGH);
      digitalWrite (pinLeds2a, HIGH);
      digitalWrite (pinLeds3a, HIGH);
     
  }
  delay (time);}
  //If the button is not pressed, sets off the leds
  digitalWrite (pinLeds1, LOW);
  digitalWrite (pinLeds2, LOW);
  digitalWrite (pinLeds3, LOW);
  digitalWrite (pinLeds4, LOW);
  digitalWrite (pinLeds1a, LOW);
  digitalWrite (pinLeds2a, LOW);
  digitalWrite (pinLeds3a, LOW);
  digitalWrite (pinLeds4a, LOW);
  }
ran = random(7);

So 0 is an option. You don't have any code to turn on any lights for 0. So it wouldn't surprise me that sometimes nothing lights up.

Thank you, I hadn't realized that. I think I was able to fix it. Thanks for your help!

Actually, I'm still stuck. I was going to just set 0s so that they lit up something, but that then loads the dice. Is there a way to make it not factor in 0?

Why nobody ever reads anything anymore? They just ask before they even look. Is it lazy? Learned helplessness? Or what?

RTFM man. https://www.arduino.cc/en/Reference/Random

It's all laid out right there in very simple language.

Delta_G:
Why nobody ever reads anything anymore? They just ask before they even look. Is it lazy? Learned helplessness? Or what?

RTFM man. random() - Arduino Reference

It's all laid out right there in very simple language.

That's what I think when I read most posters' initial (or early) posts.
They say they have searched everywhere, or spent 2 days on something.
The reference is readily available.
Examples are readily available.
You can search this forum, etc.
There's a lot of info out there!

The reference is readily available.

If you know where to look.

You can search this forum, etc.

Using google can be a double-edged sword. While it CAN find information, hey, look, there's a kitty...

There's a lot of info out there!

There's a lot of rubbish, too.

Well, I don't know if you guys saw the profanity laden rant that the OP came back with when I suggested that she read the ref. The language she used told a lot about her level of intelligence. I think we may be expecting a little too much from this one. Hopefully she got a time out and we won't have to hear anymore of that for a while.