How do photocells work?
A photocell is just a diode that is specialized to turn light into separated electrical charge. When light hits the “n-type” side of this diode, it adds energy to the valence level electrons there and moves them to the empty conduction levels. These electrons may even have enough energy to leap across the p-n junction into the “p-type” material. Once they get there, they cannot return because of the depletion region and the one-way effect of the diode. Instead, they are collected by wires attached to the “p-type” material, flow out through some electrical circuit, and return to the “n-type” material through another set of wires.