I am using a small board with LDR between two digital pins to detect when LED pulse is flashed through the power meter.
All works fine, but sometimes LED on the meter is not flashing but gets stuck in the ON position (mainly during the day when solar power is flowing the other way).
I am using pinMode(D2,"input_pullup") and detect the pulse on the falling edge.
But when LED gets stuck, it causes the whole board to hang until I either reset it or hide LDR from the light source.
I have tried changing pinMode to just pinMode(D2,"input") when the stuck LED is detected.
But as I said - for whatever reason sometimes it is just hangs the whole board.
Also, the board is battery powered and this stuck LED causes high battery drain
Looking for suggestions on how I can overcome it