randum in program not work what is wrong

i work whit the foon and the bleutooth.
programa is working but the randum not what do i wrong?

char data = 0;
int ledPin[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
int pinCount = 12;
int Number = 1;
int thisPin;
int delayTime;
int timer = 100;

void setup()
{

  for (int thisPin = 0; thisPin < pinCount; thisPin++)
  {
    Serial.begin(9600);
    pinMode(ledPin[thisPin], OUTPUT);
  }
}
void loop() {
  if (Serial.available() > 0)
  {
    data = Serial.read();
    Serial.print(data);
    Serial.print("\n");

    if (data == 'A')
      digitalWrite(2, HIGH);
    else if (data == 'a')
      digitalWrite(2, LOW);

    if (data == 'B')
      digitalWrite(3, HIGH);
    else if (data == 'b')
      digitalWrite(3, LOW);

    if (data == 'C')
      digitalWrite(4, HIGH);
    else if (data == 'c')
      digitalWrite(4, LOW);

    if (data == 'D')
      digitalWrite(5, HIGH);
    else if (data == 'd')
      digitalWrite(5, LOW);

    if (data == 'E')
      digitalWrite(6, HIGH);
    else if (data == 'e')
      digitalWrite(6, LOW);

    if (data == 'F')
      digitalWrite(7, HIGH);
    else if (data == 'f')
      digitalWrite(7, LOW);

    if (data == 'G')
      digitalWrite(8, HIGH);
    else if (data == 'g')
      digitalWrite(8, LOW);

    if (data == 'H')
      digitalWrite(9, HIGH);
    else if (data == 'h')
      digitalWrite(9, LOW);

    if (data == 'I')
      digitalWrite(10, HIGH);
    else if (data == 'i')
      digitalWrite(10, LOW);

    if (data == 'J')
      digitalWrite(11, HIGH);
    else if (data == 'j')
      digitalWrite(11, LOW);

    if (data == 'K')
      digitalWrite(12, HIGH);
    else if (data == 'k')
      digitalWrite(12, LOW);

    if (data == 'L')
      digitalWrite(13, HIGH);
    else if (data == 'l')
      digitalWrite(13, LOW);

    if (data == 'Q')
      for (int pinCount = 0; pinCount <= Number; pinCount++) {
        if (pinCount < Number) {
          thisPin = random(pinCount);
          digitalWrite(ledPin[thisPin], LOW);
        }
        else if (data == 'q' )
          delay(timer);
        for (int thisPin = 0; thisPin < pinCount; thisPin++) {
          digitalWrite(ledPin[thisPin], HIGH);
       }
     }
  }
}
    if (data == 'Q')
      for (int pinCount = 0; pinCount <= Number; pinCount++) {
        if (pinCount < Number) {
          thisPin = random(pinCount);
          digitalWrite(ledPin[thisPin], LOW);
        }

You only call random() if pinCount < Number. Number is 1 so pinCount is 0. What do you expect to get out of random(0)?

NOTE: in here you are using a local pinCount NOT the global version that was set to 12.

Steve

Your else clause is attached to the if( pinCount < Number) statement but it should be attached to the if( data == Q). You are missing a set of curly braces. You should get into the habit of ALWAYS using curly braces for your if() statements, even if there is only 1 statement in the block.

    if (data == 'Q') {
      for (int pinCount = 0; pinCount <= Number; pinCount++) {
        if (pinCount < Number) {
          thisPin = random(pinCount);
          digitalWrite(ledPin[thisPin], LOW);
        }
      }
      else if (data == 'q' ) {
        delay(timer);
        for (int thisPin = 0; thisPin < pinCount; thisPin++) {
          digitalWrite(ledPin[thisPin], HIGH);
        }
      }
    }

You probably don’t need to initialize the serial port 12 times, I think once will be sufficient

void setup()
{
  Serial.begin(9600);
  for (int thisPin = 0; thisPin < pinCount; thisPin++)
  {
    pinMode(ledPin[thisPin], OUTPUT);
  }
}

random does not produce random numbers. random reads from a list of random numbers. random will always produce the same numbers in the same order, because it always reads from the same list

if you want somewhat randomish numbers you have to tell random to select from some random location in the list

randomSeed(analogRead(A0));

it does not have to be A0. any analog pin that is not connected may be used