I'm using this sensor, same code same wiring but not working.
First in the diagram shows that the VCC should be in power 5v or 3.3v and "S" is on pin2, but the red light indicator is not lighting up in the sensor and the reading is all zero white and black surface, then I swap the "S" and Vcc and the red light is lighting but the problem is it keeps on 1 value in Serial monitor tested in black and white surface.
I don't know what's wrong because I tested my atmega2560 and its working on other sensors like distance and also motors