Check wiring
Ensure that your cable is properly connected and in good condition. Try using the same cable with another device to verify that it works. If the issue persists, swap it out for a different cable to rule out any possible damage or defects.
Try adjusting the onboard potentiometer
This board uses onboard potentiometer to set the threshold value for digital output pin. Try to rotate it with a small screwdriver.
Try isolating the sensor
The onboard photoresistor detects all surrounding light, not just light coming from the IR diode. Try to minimise the external light.