Part of this program is skipped...

Hello everyone. I have this code for an art project where it will take volume from a microphone (namely the Sparkfun Breakout Board for Electret Microphone SparkFun Electret Microphone Breakout - BOB-12758 - SparkFun Electronics), record it as volumes in the array recording[] and output it as LEDs flashing in random patterns every 200ms based on the volume. Here is my sketch: (sorry, it's not very well organised or efficient. It's also full of debug serial messages...)

int recording[50];
int micLevel;
int nomore;
int ending;
int LEDL;
int LEDS;
int avail[9];
int randy;
int pin;
int out;
int fix;

/* This program SHOULD wait until a certian mic level is reached, record the levels of speech for
 * a maximum of 10 seconds, and then flash random LEDs at the same levels of the recording...
 * But it doesn't at the moment... Why? Anyway:
 * Writer: terrabyte_aura
 * Project: Voice Your Opinion.
 */

void setup() {
  pinMode(2, OUTPUT);
  Serial.begin(9600);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  randomSeed(analogRead(0));
}

void loop() {
  for(int x = 0; micLevel <= 360; x++) { //waits for mic to be at a good level (<=360)
    micLevel = analogRead(1);
    Serial.print("Mic @ ");
    Serial.print(micLevel);
    Serial.println(" Not loud enough... (if last view of message, ignore)");
    delay(200);
  }
  for(int y = 0; y <= 50; y++) {
    micLevel = analogRead(1);
    recording[y] = micLevel;  //records the level of the microphone in the array
    Serial.print(" MicLevel: ");
    Serial.println(micLevel);
    if(micLevel <= 360) {
      nomore = nomore + 1;
      Serial.print("nomore = ");
      Serial.print(nomore);
      if(nomore == 10) {
        fix = y;
        y = 51;  //if a low level is recorded for 2 seconds, it will terminate the recording
      }
    } 
    else {
      nomore = 0;
      Serial.print(" nomore = 0"); //resets the counter for low level...
    }
    delay(200);
    Serial.print(" Fix @ ");
    Serial.print(fix);
    if(fix > 0) {
      ending = fix;
      Serial.println(" Recording End Reached");
      fix = 0;
    }
  }
  Serial.println("Playback...");  //the code doesn't excecute from the next line till the end. WHY???
  for(int z = 0; z =! ending; z++) {
    Serial.print(recording[z]);
    LEDL = recording[z];
    Serial.print(" Position:");
    Serial.println(z);
    if(LEDL <= 424) { //this takes the level at frame z and turns it into a number of LEDs
      LEDS = 1;
    }
    if(LEDL > 424 && LEDL <= 486) {
      LEDS = 2;
    }
    if(LEDL > 486 && LEDL <= 550) {
      LEDS = 3;
    }
    if(LEDL > 550 && LEDL <= 614) {
      LEDS = 4;
    }
    if(LEDL > 614 && LEDL <= 678) {
      LEDS = 5;
    }
    if(LEDL > 678 && LEDL <= 742) {
      LEDS = 6;
    }
    if(LEDL > 742 && LEDL <= 806) {
      LEDS = 7;
    }
    if(LEDL > 806 && LEDL <= 870) {
      LEDS = 8;
    }
    if(LEDL > 870) {
      LEDS = 9;
    }
    Serial.print(LEDS);
    Serial.println(" is the number of LEDS needed");
    LEDS = 10 - LEDS;
    for(int q; q =! LEDS; q++) {
      randy = random(0, 10);
      Serial.print(randy); //this chooses which LEDs will NOT be turned on...
      Serial.println(" is the random number");
      for(int zout; out =! 1; zout--) {
        if(avail[randy] == 0) { //this checks to see if the number's already been chosen
          randy = random(0, 10);
          Serial.print("previous had already been chosen... new number: ");
          Serial.println(randy);
        } 
        else {
          avail[randy] = 0;
          Serial.print(randy);
          Serial.println(" deactivated");
          out = 1;
        }
      }
    }
    out = 0;
    for(int p; p < 9; p++) {
      pin = p + 2;
      if(avail[p] == 0) { //this writes to the LEDs
        digitalWrite(pin, LOW);
        Serial.print("LOW- ");
        Serial.println(pin);
        avail[p] = 1;
      } 
      else {
        digitalWrite(pin, HIGH);
        Serial.print("HIGH- ");
        Serial.println(pin);
      }
    }
    delay(200);  //this delays the whole script
    nomore = 0;
    Serial.println("nomore reset");
  }
}

However, it doesn't perform any of the code after the "Playback..." serial message. Here's a copy of the serial monitor:

Mic @ 332 Not loud enough... (if last view of message, ignore)
Mic @ 351 Not loud enough... (if last view of message, ignore)
Mic @ 326 Not loud enough... (if last view of message, ignore)
Mic @ 355 Not loud enough... (if last view of message, ignore)
Mic @ 330 Not loud enough... (if last view of message, ignore)
Mic @ 347 Not loud enough... (if last view of message, ignore)
Mic @ 320 Not loud enough... (if last view of message, ignore)
Mic @ 392 Not loud enough... (if last view of message, ignore)
 MicLevel: 321
nomore = 1 Fix @ 0 MicLevel: 350
nomore = 2 Fix @ 0 MicLevel: 351
nomore = 3 Fix @ 0 MicLevel: 325
nomore = 4 Fix @ 0 MicLevel: 362
 nomore = 0 Fix @ 0 MicLevel: 234
nomore = 1 Fix @ 0 MicLevel: 324
nomore = 2 Fix @ 0 MicLevel: 343
nomore = 3 Fix @ 0 MicLevel: 340
nomore = 4 Fix @ 0 MicLevel: 338
nomore = 5 Fix @ 0 MicLevel: 317
nomore = 6 Fix @ 0 MicLevel: 355
nomore = 7 Fix @ 0 MicLevel: 349
nomore = 8 Fix @ 0 MicLevel: 326
nomore = 9 Fix @ 0 MicLevel: 347
nomore = 10 Fix @ 14 Recording End Reached
Playback...
Mic @ 321 Not loud enough... (if last view of message, ignore)
...
...
...

I have a feeling I've made a silly noobish mistake...
Anyway, I hope that I've given you enough information to solve my problem and many thanks in advance!

for(int z = 0; z =! ending; z++) {

Should be

for(int z = 0; z < ending; z++) {

Also print out what the value of ending is.

First of all: Thank you! That was such a quick and helpful reply despite my pretty silly mistake. The rest of the program is running fine, except that the program doesn't run this section as well...:

...
for(int q; q < LEDS; q++) {
      randy = random(0, 10);
      Serial.print(randy); //this chooses which LEDs will NOT be turned on...
      Serial.println(" is the random number");
      for(int zout; out =! 1; zout--) {
        if(avail[randy] == 0) { //this checks to see if the number's already been chosen
          randy = random(0, 10);
          Serial.print("previous had already been chosen... new number: ");
          Serial.println(randy);
        } 
        else {
          avail[randy] = 0;
          Serial.print(randy);
          Serial.println(" deactivated");
          out = 1;
        }
      }
    }
    out = 0;
    for(int p; p < 9; p++) {
      pin = p + 2;
      if(avail[p] == 0) { //this writes to the LEDs
        digitalWrite(pin, LOW);
        Serial.print("LOW- ");
        Serial.println(pin);
        avail[p] = 1;
      } 
      else {
        digitalWrite(pin, HIGH);
        Serial.print("HIGH- ");
        Serial.println(pin);
      }
    }
...

The serial monitor mentions most of that code, except it doesn't touch on random numbers or writing pins:

...
...
318 ending:14 Position:0
1 is the number of LEDS needed
nomore reset
340 ending:14 Position:1
1 is the number of LEDS needed
nomore reset
366 ending:14 Position:2
1 is the number of LEDS needed
nomore reset
326 ending:14 Position:3
1 is the number of LEDS needed
nomore reset
362 ending:14 Position:4
1 is the number of LEDS needed
nomore reset
343 ending:14 Position:5
1 is the number of LEDS needed
nomore reset
340 ending:14 Position:6
1 is the number of LEDS needed
nomore reset
327 ending:14 Position:7
1 is the number of LEDS needed
nomore reset
314 ending:14 Position:8
1 is the number of LEDS needed
nomore reset
344 ending:14 Position:9
1 is the number of LEDS needed
nomore reset
352 ending:14 Position:10
1 is the number of LEDS needed
nomore reset
352 ending:14 Position:11
1 is the number of LEDS needed
nomore reset
342 ending:14 Position:12
1 is the number of LEDS needed
nomore reset
310 ending:14 Position:13
1 is the number of LEDS needed
nomore reset
...
...

I have a feeling that this'll be another silly mistake. I guess that's how you learn, though....

for(int q;

declares a variable, but doesn't give it an initial value. It will have a value of whatever happens to be on the stack
for(int q = 0; or whatever.

for(int zout;

similar

for(int p;

again

Thanks again for the astonishingly quick reply. Now I have a different problem:

for(int q = 0; q < LEDS; q++) {
      randy = random(0, 10);
      Serial.print(randy); //this chooses which LEDs will NOT be turned on...
      Serial.println(" is the random number");
      for(int zout; out < 1; zout--) {
        if(avail[randy] == 0) { //this checks to see if the number's already been chosen
          randy = random(0, 10);
          Serial.print("previous had already been chosen... new number: ");
          Serial.println(randy);
        } 
        else {
          avail[randy] = 0;
          Serial.print(randy);
          Serial.println(" deactivated");
          out = 1;
        }
      }

This part of the code should deactivate a number of LEDs equal to the variable LEDS. However, the code always only deactivates one LED and then runs, so the code always flashes all but one LED. How do I fix this so that it deactivates all the LEDs based on the variable LEDS? Here's a copy of that part of the system monitor: (<--- notes aren't actual output, they're just extra notes I've added now)

371 ending:21 Position:11
9 is the number of LEDS to be subtracted...
6 is the random number
6 deactivated
4 is the random number      <--- Where's the deactivated on the next line?
6 is the random number      <--- ?
8 is the random number
5 is the random number
4 is the random number
0 is the random number
4 is the random number
3 is the random number
HIGH- 2
HIGH- 3
HIGH- 4
HIGH- 5
HIGH- 6
HIGH- 7
LOW- 8
HIGH- 9
HIGH- 10
nomore reset

Thanks for any help! One other question, is there a place in this forum for posting completed creations? I'll post this artwork here when I'm done.

 for(int zout; out < 1; zout--) {

No, you have a very similar problem.
See my last post

I already did that. I also tried setting int out = 0; at the top of the script, which now means that it does it correctly the first time in the entire program, but not any other time. Here's the full script:

int recording[50];
int micLevel = 0;
int nomore = 0;
int ending = 0;
int LEDL = 0;
int LEDS = 0;
int avail[9];
int randy = 0;
int pin = 0;
int out = 0;
int fix = 0;

/* This program SHOULD wait until a certian mic level is reached, record the levels of speech for
 * a maximum of 10 seconds, and then flash random LEDs at the same levels of the recording...
 * But it doesn't at the moment... Why? Anyway:
 * Writer: terrabyte_aura
 * Project: Voice Your Opinion.
 */

void setup() {
  pinMode(2, OUTPUT);
  Serial.begin(9600);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  randomSeed(analogRead(0));
}

void loop() {
  for(int x = 0; micLevel <= 360; x++) { //waits for mic to be at a good level (<=360)
    micLevel = analogRead(1);
    Serial.print("Mic @ ");
    Serial.print(micLevel);
    Serial.println(" Not loud enough... (if last view of message, ignore)");
    delay(200);
  }
  for(int y = 0; y <= 50; y++) {
    micLevel = analogRead(1);
    recording[y] = micLevel;  //records the level of the microphone in the array
    Serial.print(" MicLevel: ");
    Serial.println(micLevel);
    if(micLevel <= 360) {
      nomore = nomore + 1;
      Serial.print("nomore = ");
      Serial.print(nomore);
      if(nomore == 10) {
        fix = y;
        y = 51;  //if a low level is recorded for 2 seconds, it will terminate the recording
      }
    } 
    else {
      nomore = 0;
      Serial.print(" nomore = 0"); //resets the counter for low level...
    }
    delay(200);
    Serial.print(" Fix @ ");
    Serial.print(fix);
    if(fix > 0) {
      ending = fix;
      Serial.println(" Recording End Reached");
      fix = 0;
    }
  }
  Serial.println("Playback...");  //the code doesn't excecute from the next line till the end. WHY???
  for(int z = 0; z < ending; z++) {
    Serial.print(recording[z]);
    Serial.print(" ending:");
    Serial.print(ending);
    LEDL = recording[z];
    Serial.print(" Position:");
    Serial.println(z);
    if(LEDL <= 424) { //this takes the level at frame z and turns it into a number of LEDs
      LEDS = 9;
    }
    if(LEDL > 424 && LEDL <= 486) {
      LEDS = 8;
    }
    if(LEDL > 486 && LEDL <= 550) {
      LEDS = 7;
    }
    if(LEDL > 550 && LEDL <= 614) {
      LEDS = 6;
    }
    if(LEDL > 614 && LEDL <= 678) {
      LEDS = 5;
    }
    if(LEDL > 678 && LEDL <= 742) {
      LEDS = 4;
    }
    if(LEDL > 742 && LEDL <= 806) {
      LEDS = 3;
    }
    if(LEDL > 806 && LEDL <= 870) {
      LEDS = 2;
    }
    if(LEDL > 870) {
      LEDS = 1;
    }
    Serial.print(LEDS);
    Serial.println(" is the number of LEDS to be subtracted...");
    for(int q = 0; q < LEDS; q++) {
      randy = random(0, 10);
      Serial.print(randy); //this chooses which LEDs will NOT be turned on...
      Serial.println(" is the random number");
      for(int zout = 0; out < 1; zout--) {
        if(avail[randy] == 0) { //this checks to see if the number's already been chosen
          randy = random(0, 10);
          Serial.print("previous had already been chosen... new number: ");
          Serial.println(randy);
        } 
        else {
          avail[randy] = 0;
          Serial.print(randy);
          Serial.println(" deactivated");
          out = 1;
        }
      }
    }
    out = 0;
    for(int p = 0; p < 9; p++) {
      pin = p + 2;
      if(avail[p] == 0) { //this writes to the LEDs
        digitalWrite(pin, LOW);
        Serial.print("LOW- ");
        Serial.println(pin);
        avail[p] = 1;
      } 
      else {
        digitalWrite(pin, HIGH);
        Serial.print("HIGH- ");
        Serial.println(pin);
      }
    }
    delay(200);  //this delays the whole script
    nomore = 0;
    Serial.println("nomore reset");
    for(int a = 0; a < 9; a++) {
      pin = a + 2;
      digitalWrite(pin, LOW);
      avail[a] = 1;
    }
  }
}

And the serial monitor:

Mic @ 201 Not loud enough... (if last view of message, ignore)
Mic @ 336 Not loud enough... (if last view of message, ignore)
Mic @ 327 Not loud enough... (if last view of message, ignore)
Mic @ 351 Not loud enough... (if last view of message, ignore)
Mic @ 316 Not loud enough... (if last view of message, ignore)
Mic @ 366 Not loud enough... (if last view of message, ignore)
 MicLevel: 346
nomore = 1 Fix @ 0 MicLevel: 325
nomore = 2 Fix @ 0 MicLevel: 328
nomore = 3 Fix @ 0 MicLevel: 333
nomore = 4 Fix @ 0 MicLevel: 354
nomore = 5 Fix @ 0 MicLevel: 314
nomore = 6 Fix @ 0 MicLevel: 353
nomore = 7 Fix @ 0 MicLevel: 338
nomore = 8 Fix @ 0 MicLevel: 344
nomore = 9 Fix @ 0 MicLevel: 335
nomore = 10 Fix @ 9 Recording End Reached
Playback...
346 ending:9 Position:0
9 is the number of LEDS to be subtracted...
3 is the random number
3 deactivated
8 is the random number
4 is the random number
0 is the random number
0 is the random number
0 is the random number
4 is the random number
8 is the random number
1 is the random number
HIGH- 2
HIGH- 3
HIGH- 4
LOW- 5
HIGH- 6
HIGH- 7
HIGH- 8
HIGH- 9
HIGH- 10
nomore reset
325 ending:9 Position:1
9 is the number of LEDS to be subtracted...
0 is the random number
0 deactivated
8 is the random number
8 is the random number
4 is the random number
9 is the random number
4 is the random number
1 is the random number
1 is the random number
8 is the random number
LOW- 2
HIGH- 3
HIGH- 4
HIGH- 5
HIGH- 6
HIGH- 7
HIGH- 8
HIGH- 9
HIGH- 10
nomore reset
328 ending:9 Position:2
9 is the number of LEDS to be subtracted...
6 is the random number
6 deactivated
3 is the random number
4 is the random number
4 is the random number
9 is the random number
3 is the random number
7 is the random number
3 is the random number
0 is the random number
HIGH- 2
HIGH- 3
HIGH- 4
HIGH- 5
HIGH- 6
HIGH- 7
LOW- 8
HIGH- 9
HIGH- 10
nomore reset
333 ending:9 Position:3
9 is the number of LEDS to be subtracted...
4 is the random number
4 deactivated
3 is the random number
2 is the random number
9 is the random number
7 is the random number
1 is the random number
8 is the random number
4 is the random number
2 is the random number
HIGH- 2
HIGH- 3
HIGH- 4
HIGH- 5
LOW- 6
HIGH- 7
HIGH- 8
HIGH- 9
HIGH- 10
nomore reset
354 ending:9 Position:4
9 is the number of LEDS to be subtracted...
3 is the random number
3 deactivated
0 is the random number
6 is the random number
6 is the random number
0 is the random number
5 is the random number
7 is the random number
1 is the random number
7 is the random number
HIGH- 2
HIGH- 3
HIGH- 4
LOW- 5
HIGH- 6
HIGH- 7
HIGH- 8
HIGH- 9
HIGH- 10
nomore reset
314 ending:9 Position:5
9 is the number of LEDS to be subtracted...
4 is the random number
4 deactivated
3 is the random number
0 is the random number
1 is the random number
6 is the random number
5 is the random number
2 is the random number
5 is the random number
4 is the random number
HIGH- 2
HIGH- 3
HIGH- 4
HIGH- 5
LOW- 6
HIGH- 7
HIGH- 8
HIGH- 9
HIGH- 10
nomore reset
353 ending:9 Position:6
9 is the number of LEDS to be subtracted...
1 is the random number
1 deactivated
1 is the random number
2 is the random number
8 is the random number
2 is the random number
1 is the random number
7 is the random number
7 is the random number
6 is the random number
HIGH- 2
LOW- 3
HIGH- 4
HIGH- 5
HIGH- 6
HIGH- 7
HIGH- 8
HIGH- 9
HIGH- 10
nomore reset
...

Thanks again, and thanks in advance for any help!

is there a place in this forum for posting completed creations?

The exhibition section.

for(int x = 0; micLevel <= 360; x++)

What is x used for?
Did you just want a while loop?

for(int y = 0; y <= 50; y++) {
    micLevel = analogRead(1);
    recording[y]

Indices for "recording" run 0 to 49 - you don't own "recording [50]", so you should not be writing to it.

for(int y = 0; y < 50; y++) {
    micLevel = analogRead(1);
    recording[y]

Sorry for the radio silence, but thanks to you guys' help, I've managed to solve the problem. The code picks LEDs to function rather than picking LEDs NOT to function, and after a lot of edits and silly mistakes, it's done! Here it is:

int recording[50];
int micLevel = 0;
int nomore = 0;
int ending = 0;
int LEDL = 0;
int LEDS = 0;
int avail[9];
int randy = 0;
int pin = 0;
int out = 0;
int fix = 0;
int ready = 1;
int readyornot = 0;

/* This program waits until a certian mic level is reached, record the levels of speech for
 * a maximum of 10 seconds, and then flash random LEDs at the same levels of the recording...
 * It's fixed now ;) This is my first real project, I guess. This should get me a fine art GCSE! Anyway:
 * Writer: terrabyte_aura
 * Project: Voice Your Opinion.
 */

void setup() {
  pinMode(2, OUTPUT);
  Serial.begin(9600);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  randomSeed(analogRead(0));
  avail[0] = 1;
  avail[1] = 1;
  avail[2] = 1;
  avail[3] = 1;
  avail[4] = 1;
  avail[5] = 1;
  avail[6] = 1;
  avail[7] = 1;
  avail[8] = 1;
  digitalWrite(2, HIGH);
  digitalWrite(3, HIGH);
  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(10, HIGH);
  delay(400);
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
}

void loop() {
  while(micLevel <= 360) { //waits for mic to be at a good level (<=360)
    micLevel = analogRead(1);
    Serial.print("Mic @ ");
    Serial.print(micLevel);
    Serial.println(" Not loud enough... (if last view of message, ignore)");
    delay(200);
  }
  for(int y = 0; y < 50; y++) {
    micLevel = analogRead(1);
    recording[y] = micLevel;  //records the level of the microphone in the array
    Serial.print(" MicLevel: ");
    Serial.println(micLevel);
    if(micLevel <= 360) {
      nomore = nomore + 1;
      Serial.print("nomore = ");
      Serial.print(nomore);
      if(nomore == 10) {
        fix = y;
        y = 50;  //if a low level is recorded for 2 seconds, it will terminate the recording
      }
    } 
    else {
      nomore = 0;
      Serial.print(" nomore = 0"); //resets the counter for low level...
    }
    delay(200);
    Serial.print(" Fix @ ");
    Serial.print(fix);
    if(fix > 0) {
      ending = fix;
      Serial.println(" Recording End Reached");
      fix = 0;
    }
  }
  Serial.println("FLASH!");
  digitalWrite(2, HIGH);
  digitalWrite(3, HIGH);
  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(10, HIGH);
  delay(400);
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
  Serial.println("Playback...");
  for(int z = 0; z < ending; z++) {
    Serial.print(recording[z]);
    Serial.print(" ending:");
    Serial.print(ending);
    LEDL = recording[z];
    Serial.print(" Position:");
    Serial.println(z);
    if(LEDL <= 380) { //this takes the level at frame z and turns it into a number of LEDs
      LEDS = 1;
    }
    if(LEDL > 380 && LEDL <= 411) {
      LEDS = 2;
    }
    if(LEDL > 411 && LEDL <= 442) {
      LEDS = 3;
    }
    if(LEDL > 442 && LEDL <= 473) {
      LEDS = 4;
    }
    if(LEDL > 473 && LEDL <= 504) {
      LEDS = 5;
    }
    if(LEDL > 504 && LEDL <= 535) {
      LEDS = 6;
    }
    if(LEDL > 535 && LEDL <= 566) {
      LEDS = 7;
    }
    if(LEDL > 566 && LEDL <= 870) {
      LEDS = 8;
    }
    if(LEDL > 870) {
      LEDS = 9;
    }
    Serial.print(LEDS);
    Serial.println(" is the number of LEDS to be on...");
    while(readyornot == 0) {
      out = 0;
      randy = random(0, 10);
      Serial.print(randy); //this chooses which LEDs will NOT be turned on...
      Serial.println(" is the random number");
      out = 0;
      while(out < 1) {
        if(avail[randy] == 0) { //this checks to see if the number's already been chosen
          randy = random(0, 10);
          Serial.print("previous had already been chosen... new number: ");
          Serial.println(randy);
        } 
        else {
          avail[randy] = 0;
          Serial.print(randy);
          Serial.println(" activated");
          out = 1;
          ready = ready + 1;
          Serial.print("Ready: ");
          Serial.println(ready);
        }
        if(ready > LEDS) {
          Serial.println("READY");
          readyornot = 1;
        }
      }
    }
    ready = 1;
    readyornot = 0;
    out = 0;
    for(int p = 0; p < 9; p++) {
      pin = p + 2;
      if(avail[p] == 1) { //this writes to the LEDs
        digitalWrite(pin, LOW);
        Serial.print("LOW- ");
        Serial.println(pin);
      } 
      else {
        digitalWrite(pin, HIGH);
        Serial.print("HIGH- ");
        Serial.println(pin);
        avail[p] = 1;
      }
    }
    delay(200);  //this delays the whole script
    nomore = 0;
    Serial.println("nomore reset");
    for(int a = 0; a < 9; a++) {
      pin = a + 2;
      digitalWrite(pin, LOW);
      avail[a] = 1;
    }
  }
}

AWOL: You were right about the while loops.

Also, I'll post this in the exhibition section when I've completed the art bit in the exam on Monday week.