LED's remain in HIGH state

I am using a new arduino uno (i believe rev.2).
Arduino powered externally with 5.5v supply.
I breaboarded a PIR, LDR, and 3 LED’s. (Code attached)…First timer, code is hacked up pretty bad I think.
The PIR is powered externally with 5.5v supply.
Simply, when its dark and motion is detected, 1 led fades on and off, the other two turn on and this continues until motion stops. At this point everything works fine. (its still dark)
Problem is: If we start in a dark condition, create motion activating PIR, LED’s come on…but If I turn the lights on WHILE the LED’s are on, they stay on, they don’t go off when motion stops.

This example shows the output of an analogRead() of a Photocell.
By M.Gonzalez
The example code is in the public domain

int photocellPin = 0;// Photocell connected to analog pin 0
int photocellVal = 0; // define photocell variable
int ledPin = 9;// LED connected to digital pin 9
int ledState = 0;//state of the led 
int fadeDown = 30;//delay per fade
int fadeUp = 20;//delay per fade
int minLight = 20;//min light threshold
int maxLight = 20;//max light threshold
//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 30;        

//the time when the sensor outputs a low impulse
long unsigned int lowIn;         

//the amount of milliseconds the sensor has to be low 
//before we assume all motion has stopped
long unsigned int pause = 5000;  

boolean lockLow = true;
boolean takeLowTime;  

//int ldrPin = 11;
int pirPin = 2;    //the digital pin connected to the PIR sensor's output
int ledPin1 = 3;
int ledPin2 = 4;
int ledPin3 = 5;

void setup() {
  pinMode(photocellPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(pirPin, INPUT);
  //pinMode (ldrPin, INPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode (ledPin2, OUTPUT);
  pinMode (ledPin3, OUTPUT);
  digitalWrite(pirPin, LOW);

  //give the sensor some time to calibrate
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
void loop() {
  photocellVal = analogRead(photocellPin);

  if (photocellVal < minLight and ledState == 0){
  if(digitalRead(pirPin) == HIGH){
       // fade in from min to max in increments of 5 points:
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
    // sets the value (range from 0 to 255):
    analogWrite(ledPin1, fadeValue);         
    // wait for 30 milliseconds to see the dimming effect    
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
         //makes sure we wait for a transition to LOW before any further output is made:
         lockLow = false;            
         Serial.print("motion detected at ");
         Serial.println(" sec"); 
         takeLowTime = true;
    //Serial.println("fade up");
    if(photocellVal > minLight and ledState == 1);
    if(digitalRead(pirPin) == LOW){       
       digitalWrite(ledPin1, LOW);  //the led visualizes the sensors output pin state
       digitalWrite(ledPin2, LOW);
       digitalWrite(ledPin3, LOW);
        lowIn = millis();          //save the time of the transition from high to LOW
        takeLowTime = false;       //make sure this is only done at the start of a LOW phase
       //if the sensor is low for more than the given pause, 
       //we assume that no more motion is going to happen
       if(!lockLow && millis() - lowIn > pause){  
           //makes sure this block of code is only executed again after 
           //a new motion sequence has been detected
           lockLow = true;                        
           Serial.print("motion ended at ");      //output
           Serial.print((millis() - pause)/1000);
           Serial.println(" sec");

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

if(photocellVal > minLight and ledState == 1);
and &&

Good morning Larry, Thank you for the reply...however I do have the AND in there...not sure if maybe I need to relocate it? Best regards, Jack

Created pirVal and used it with the AND, as you suggested...and it works...thank you very much Larry.