Much better to post your code with code tags, then it looks like this:
const int kPin_Photocell = A0;
const int kPinLed = 2;
const int kPinMotor1 = 3;
const int kPinMotor2 = 4;
int integer;
void setup() {
pinMode(kPinLed, OUTPUT);
pinMode(kPinMotor1, OUTPUT);
pinMode(kPinMotor2, OUTPUT);
Serial.begin(9600);
}
void loop(){
int value=analogRead(kPin_Photocell);
Serial.print("Analog Reading = ");
Serial.print(value);
if(value<500&&integer==0){
Serial.println(" - Dark");
digitalWrite(kPinLed, HIGH);
digitalWrite(kPinMotor1, HIGH);
digitalWrite(kPinMotor2, LOW);
delay(15000);
integer=1;
}
else if(value>500){
Serial.println(" - Bright");
digitalWrite(kPinMotor1, LOW);
digitalWrite(kPinMotor2, LOW);
digitalWrite(kPinLed, LOW);
}
}
You set the threshold to 500, not 400.
If it equals 500, nothing evaluates as true. Use a <= for dark or a >= for light (as you prefer) to catch the 500 reading as well.
You don't reset this oddly named "integer" flag - why is that even an int, not a bool? Your other constants can be a byte instead of an int. Saves memory. Not important for this sketch but for larger ones it is, so make it a habit to choose the smallest possible data type.