That code won't even compile, because analogValue is not defined for the loop function.
void loop()
{
int sensorValue = analogRead(pinlight);
delay(1000);
if(analogValue < ANALOG_THRESHOLD)
{
Start with one of the example programs and make sure you understand how it works before making any changes.
Hint: the function advancedRead() is a bit useless, because it prints stuff but returns no values.