Could use some coding help.

you should go for a pure electronic system where the sensor power the led then