Random Binary LED Checktest

Hi I have made a code to get random numbers between 0-256 and then output it as binary to LEDs and show the binary sequence. Both the random number and the binary sequence must be displayed to the monitor which is working fine. I am having a little trouble with the check test which somewhat has to resemble: Check-test: d02^7+d12^6+d22^5+d32^4+d42^3+d52^2+d62^1+d72^0 = random number.

Heres the code:

int ledPins[] = {2,3,4,5,6,7,8,9};
int d[] = {1,2,4,8,16,32,64,128}; 
long randNumber;
void setup()
{
  Serial.begin(9600);
  //Set each pin connected to an LED to output mode (pulling high (on) or low (off)
  for(int i = 0; i < 8; i++)
  {        
      pinMode(ledPins[i],OUTPUT); //we use this to set each LED pin to output
  } 
  randomSeed(analogRead(0));
  for (int i=0; i<8; i++)
   {
    digitalWrite(ledPins[i], HIGH);
    delay(500);
    continue;
    while(1){}
   }
}

void loop()                   
{
  for(int i=0; i<8; i++)
  {
    digitalWrite(ledPins[i], LOW);
    delay(5);
    continue;
    while(1){}
  }
  randNumber = random(0,256);
  Serial.print("\n");
  Serial.println("Random Integer: ");
  Serial.println(randNumber);
  Serial.println("Binary Sequence: ");  
  for (int i=0; i<8; i++) 
  {
    if (randNumber%2)
    {
      digitalWrite(ledPins[i], HIGH);
      Serial.print("1");
    }
    else
    {
      digitalWrite(ledPins[i], LOW);
      Serial.print("0");
    }
    randNumber/=2;
    digitalRead(ledPins[i]);
    if (ledPins[i]=HIGH)
    {
   
    }
    else
    {
      
    }
    
    delay(300);
  }
  delay(4000);
}
    while(1){}

How long do you think it will be before 1 becomes untrue and the program progresses to the next line of code?

I have made a code to get random numbers between 0-256 and then output it as binary to LEDs and show the binary sequence.

Using only 8 LEDs ?

Leaving that aside for now, what and where is the Check-test that you refer to ? Is it a function that belongs in the program and if so, have you written it ?

Diegoc28:
I am having a little trouble with the check test which somewhat has to resemble: Check-test: d02^7+d12^6+d22^5+d32^4+d42^3+d52^2+d62^1+d72^0 = random number.

Well, you can't use '^' for exponentiation in C or C++ so you can start by using 1<<n (shift left) to get powers of 2:

d0*(1<<7)+d1*(1<<6)+d2*(1<<5)+d3*(1<<4)+d4*(1<<3)+d5*(1<<2)+d6*(1<<1)+d7*(1<<0) = random number

It appears that all the 'd0-7' variables have a value of 0 or 1 so you can get rid of the multiplies:

d0<<7+d1<<6+d2<<5+d3<<4+d4<<3+d5<<2+d6<<1+d7<<0 = random number

If this is a 'test' you probably want to do a comparison ('==') and not an assignment ('='):

d0<<7+d1<<6+d2<<5+d3<<4+d4<<3+d5<<2+d6<<1+d7<<0 == random number

And you are probably comparing against a variable which can't have a space in the name:

d0<<7+d1<<6+d2<<5+d3<<4+d4<<3+d5<<2+d6<<1+d7<<0 == randomNumber

And you probably want to make a decision based on the test:

  if (d0<<7+d1<<6+d2<<5+d3<<4+d4<<3+d5<<2+d6<<1+d7<<0 == randomNumber)
  {
  }