Blink LED's Random - Where did I go wrong?

I (once again) thought this would be easy but its late and Im getting tired 8)

All I want to do is run a loop to blink 3 LEDs in random ways: … seemed easy but it doesn’t work…

int Led[] = {6,9,10};
int State[] ={0,1};
int wait = random(15,100);

for (int x=0; x<500; x++) {
digitalWrite(Led[random(0,2)],State[random(0,1)]);
delay(wait);
}

Can you post the whole sketch please? I don't see setup or loop, or where you are initializing the pins to output.

read the documentation of random:

Syntax
random(min, max)
Parameters
min - lower bound of the random value, inclusive (optional)
max - upper bound of the random value, exclusive

Look at blink without delay - in examples.

Mark

This will work. You have set the upper bound of random 1 too low, so State[random(0,1)] will always be 0. Also Led[random(0,2)] will never adress Led[2]. The lower bond on the random function is also unecessary. And i believe you wanted the random time included in the loop.

int Led[] = {6,9,10};
int State[] ={0,1};

void setup(){
  pinMode(6, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
}//setup()

void loop(){
  for (int x=0; x<500; x++) {
    digitalWrite(Led[random(3)],State[random(2)]);
    delay(random(15,100));
  }
}//loop()

Or even simpler, lose "State"

  digitalWrite(Led[random(3)], random(2));