Illuminance regulator of a room

we need help.. we have a project needing a program in this situation

that automatically dims or brighten the lights according to the light ambience. Meaning when the light intensity in the room is lower than the preset level, the LEDs or light will brighten up, whereas if the room is brighter than the preset level, the lights or LEDs will dim.

wat is the best code to use for this. Thanksss for the answers

Assuming that the light is dimmed by PWM, adjust the PWM duty cycle depending on current light intensity, measured e.g. using a LDR:

int currentIntensity = analogRead(LDRpin);
if (currentIntensity < desiredIntensity)
 analogWrite(LEDpin, ++dutyCycle); //increase brightness
else if (currentIntensity > desiredIntensity)
  analogWrite(LEDpin, --dutyCycle); //decrease brightness

Look up how to connect a LDR and a LED to an Arduino in the Learning section, or search the Forum.
The output procedures can vary, depending on your room light installation.