Sunlight shines on the semiconductor p-n junction to form new hole-electron pairs. Under the action of the p-n junction electric field, holes flow from the p-region to the n-region, and electrons flow from the n region to the p-region, and a current is formed after the circuit is connected. This is how the solar panel systems work.