Problem connecting the brightness of randomly flickering LEDs to sensor value

Hey everybody. I’m working on a project that involves a bunch of LEDs integrated into a piece of aged, worm-eaten wood. The idea is that the LEDs will flicker randomly, but appear brighter on average as the temperature goes up. I’m using a thermistor to measure the ambient temperature. I am using a frankenstein’d version of a few different codes I’ve found online, but the problem is that no matter what I change the values to the LEDs don’t seem to have any variation in blinking. The flickering effect is way more subtle than I’d like, and doesn’t seem to change at all. I’ve played around with a few values to try and get any sort of visual response, but I’m not sure what I’m doing wrong. I’m pretty new to programming, so I wouldn’t be surprised if it’s just a simple mistake, but it’s sure as hell stumping me.

Here’s the code I’m using.

/*
 * randomly flickering LEDs
 */
int lightPin = 0;
int ledPin[] = {
 3, 5, 6, 9, 10, 11};              // pwm pins only
int ledState[3];                 // last state of each led
long randNumber;

int sensorValue = 0;

void setup() {
  Serial.begin(9600);
  for (int i=0; i<=4; i++){      // set each led pin as an output
    pinMode(ledPin[i], OUTPUT);       
  }
  randomSeed(analogRead(1 ));     // seed the rnd generator with noise from unused pin

  for (int i=0; i<=4; i++){      // init each led with a random value
    ledState[i] = random(20, 201);
  }
}

void loop(){ 
  sensorValue = analogRead(lightPin);
   Serial.println(sensorValue);
  for (int i=0; i<=4; i++){                  // for each led:
    analogWrite(ledPin[i], ledState[i]);     // set the pwm value of that pin determined previously
    randNumber = random(0, 255);            // generate new random number and add that to the current value
    ledState[i] += randNumber;    // that range can be tweaked to change the intensity of the flickering
     if(sensorValue<450){
      if (ledState[i] > 75) {                 // clamp the limits of the pwm values so it remains within
      ledState[i] = 75;}                     // a pleasing range as well as the pwm range
   
      if (ledState[i] < 10) {
      ledState[i] = 10;
    }
  }
  else if (sensorValue>480){
     if (ledState[i] > 95) {                 // clamp the limits of the pwm values so it remains within
      ledState[i] = 95;                     // a pleasing range as well as the pwm range
    }
    if (ledState[i] < 75) {
      ledState[i] = 75;
    }
  }
    else if (sensorValue>500){
     if (ledState[i] > 150) {                 // clamp the limits of the pwm values so it remains within
      ledState[i] = 150;                     // a pleasing range as well as the pwm range
    }
    if (ledState[i] < 20) {
      ledState[i] = 20;
    }
  }
    else if (sensorValue>515){
     if (ledState[i] > 200) {                 // clamp the limits of the pwm values so it remains within
      ledState[i] = 200;                     // a pleasing range as well as the pwm range
    }
    if (ledState[i] < 50) {
      ledState[i] = 50;
    }
  }
    else if (sensorValue>525){
     if (ledState[i] > 240) {                 // clamp the limits of the pwm values so it remains within
      ledState[i] = 240;                     // a pleasing range as well as the pwm range
    }
    if (ledState[i] < 25) {
      ledState[i] = 25;
    }
  }
    else{
     if (ledState[i] > 255) {                 // clamp the limits of the pwm values so it remains within
      ledState[i] = 255;                     // a pleasing range as well as the pwm range
    }
    if (ledState[i] < 0) {
      ledState[i] = 0;
    }
  }
  delay(100);    // the delay between changes
  }}

Any help would be greatly appreciated.

You have 5 LEDs and only room in the ledState array for 3 values

int ledPin[] = {
 3, 5, 6, 9, 10, 11};              // pwm pins only

There are 6 values in the array.

  for (int i=0; i<=4; i++){      // set each led pin as an output
    pinMode(ledPin[i], OUTPUT);       
  }

You are setting 5 of them to OUTPUT. Unnecessarily, since analogWrite() makes the pins OUTPUT, too.

  for (int i=0; i<=4; i++){                  // for each led:
    analogWrite(ledPin[i], ledState[i]);     // set the pwm value of that pin determined previously

Again, you are only writing to 5 of the pins.

int ledState[3];                 // last state of each led

It would be good if the number of states matched the number of pins.

Look at the constrain() function, and get rid of a lot of code.

  }}

The only correct number of curly braces on one line is ONE.

Use Tools + Auto Format before posting code again.

Thank you so much, that was extremely helpful and I have it working now. Thanks for the tips about constrain() and autoformat. As I said, I'm a total noob so sorry for the faux pas.