Automatic Room Light Intensity Control System

I built something similar for under and over cabinet lighting for my kitchen. It uses a PIR for movement detection to turn on the lights when movement is detected in the kitchen but the light sensor is only used for detecting ambient light to determine whether or not the lights need to be turned on. It won't turn them on during the day or if the kitchen lights are on. And if they are on then the kitchen lights are turned on, it will fade them out. The code is very simple.

#define ledPin 5        // Top LED strip
#define ledPin1 6       // Middle LED strip
#define ledPin2 9       // Bottom LED strip
#define analogPin A0    // potentiometer connected to input 0
#define motionSensor A1 // motion sensor connected to input 1
#define lightPin A2     // Light sensor connected to input 2
#define lightThresh 15 // Light threshold
#define maxbright 255
int motion = 0;         // variable to store the read value
int curLight = 0;       //current light level
void setup()
{
  pinMode(ledPin, OUTPUT);   // sets the pin as output
  pinMode(ledPin1, OUTPUT);   // sets the pin as output
  pinMode(ledPin2, OUTPUT);   // sets the pin as output
  Serial.begin(9600);
}

void loop()
{
//  analogWrite(ledPin, val / 4);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
  if (analogRead(motionSensor)>0 && analogRead(lightPin) < lightThresh) {
    turnon();
    delay(1000);
    while(analogRead(motionSensor)>0 && analogRead(lightPin)<(lightThresh+15)){
      delay(200);
      Serial.println(analogRead(lightPin));
    }
    turnoff();
  }
      Serial.println(analogRead(lightPin));
}

void turnon(){
  for (int i =0; i<maxbright; i++){
    analogWrite(ledPin, i);
    analogWrite(ledPin1, i);
    analogWrite(ledPin2, i);
      Serial.println(analogRead(lightPin));
    delay(25);
  }
}

void turnoff(){
  for (int i =maxbright; i>=0; i--){
    analogWrite(ledPin, i);
    analogWrite(ledPin1, i);
    if (i<25) analogWrite(ledPin2, i);
    delay(35);
  }
}