Programming a photocell with if/else and analogWrite

I’m pretty newb at working with an Arduino (and electronics/circuitry for that matter) and can’t seem to figure out how to close this if/else conditional. I’m trying to use a photocell as a light-reactive night light, so that the LED turns on when the photocell isn’t receiving enough light. When I first upload my code, with adequate light, it works; the LED won’t turn on. When I turn off my lamp, the light comes on, as its supposed to. HOWEVER, once I turn the lamp back on, the LED doesn’t go off. I’m using a tri-color LED with analogWrite rules. Can’t quite figure out how to close this to make the LED turn off successfully. Thanks in advance for the help!

void setup()  { 
 Serial.begin(9600);
} 
 
void loop()  {
 
int sensorValue = analogRead(A0);
if (sensorValue < 200) {
  for(int b = 0 ; b <= 255; b=b+5) 
  { 
      for(int g = 0 ; g <= 255; g=g+5) 
    { 
      for(int r= 0 ; r <= 255; r=r+5) 
       { 
        analogWrite(9, b);         
        analogWrite(10, g);         
        analogWrite(11, r);    
        delay(10);
       }
 
      } 
    }
  }
  else {
    analogWrite(9, LOW);
    analogWrite(10, LOW);
    analogWrite(11, LOW);
  }
 
}

This code takes 1,250,000 ms to run…

  for(int b = 0 ; b <= 255; b=b+5) 
  { 
      for(int g = 0 ; g <= 255; g=g+5) 
    { 
      for(int r= 0 ; r <= 255; r=r+5) 
       { 
        analogWrite(9, b);         
        analogWrite(10, g);         
        analogWrite(11, r);    
        delay(10);
       }
 
      } 
    }

If you wait 20 minutes the LED will turn off.