Error

redneck:

if (averagelightLevel >=  600)

I guess that averagelightLevel is a function and you are trying to compare the return value from the function:

if (averagelightLevel() >=  600)

Of course, I shouldn't have to guess.