I am trying to work with arduino mega 2560 and sensor e18-d80nk. I have connected red with 5V, black with GND and yellow with pin 2. written following program
Even no object is in front of sensor, it still shows as Object detected. I read somewhere that I need to connect 1k resistor between pin 2 and yellow wire. But no changes in result.
I tried your method, but still problem was there. I checked with sensor manufacturer, they have mentioned that sensor works on 6-36 VDC and arduino gives 5V, so I connected sensor to external supply of 12V. Now its working but signal also has 12V, so I can't connect it to arduino.