How do I turn on or off an array of LEDs based on the value of a variable?
Here is a suggestion with the led pins in an array that you loop over.

I suggest making the array global, so put it outside any functions (usually at the top):

byte led_pins[] = {pin1, pin2, pin3, pin4, pin5, pin6, pin7, pin8};


Then put this in your loop (assumes that you have a int called cleanCount that is in scope:

const int increment = 100;

for (int i = 0; i &lt; sizeof(led_pins) / sizeof(led_pins[0]); i++) {
  boolean onOrOff = cleanCount &gt; (i+1) * increment;
  digitalWrite(led_pins[i], onOrOff);
}