Photoresistor Light Timer (Please Help)

I'm trying to write a program that uses a photoresistor to time how long a light is on. I've tried 2 programs, one with the sectimer library:

#include <secTimer.h>
int lightPin = 0;
secTimer myTimer;

void setup() {
Serial.begin(9600); //Begin serial communcation
myTimer.startTimer(); //start the timer

}

void loop() {
int test = analogRead(lightPin);
if (int test = 0); {
myTimer.stopTimer();
}
}

And one with the millis() command:

int lightPin = 0;
bool Light = true;

void setup() {
Serial.begin(9600); //Begin serial communcation
Serial.println(millis());
}

void loop() {
while (bool Light = true); {
delay(50);
Serial.println(millis());
int test = (analogRead(lightPin));
if (int test = 5){
bool Light = false;
}

}
}

They still don't work :frowning: The sectimer one only displays zeros, and the millis() one never seems to print the end time. Any suggestions of how I could get them to work?

if (int test = 5) // that puts a value of 5 in the value "test", and makes "Light" always false.

Big difference between = (assign) and == (compare).
But better use < or > or <= or >= here if you don't want to wait until the light level is exactly five.
Leo..