Photoelectric sensor, arduino and external power supply

Thank you for the help, try it today and it works!

I'm trying to understand it today, this is what I came up with so far:
1.Connecting yellow to GND of arduino is to let arduino had a refernce point to determine the signal voltage.
2.When the sensor detects an object, the yellow wire and black wire close to form a circuit, allowing 5V to flow into the input and eventually into the GND.

Am I right?