added code for light sensor, not tested
Fixed nightlight bugs