In this device electrons from the n side move to the p side to fill up the holes. This leaves, in the vicinity of the junction between the two, positively charged ions on the n side (atoms who have lost an electron) and negatively charged ions on the p side (atoms who have gained an electron).
There is thus a permanent electric field existing in the vicinity of the junction between the two semiconductors. This has a number of important applications.
AC/DC converters: The electric field of the diode has the effect that it will oppose the flow of charges in one direction but will allow them to flow in the other direction. If one now subjects this diode to an alternating (AC) current, where the current alternately flows in one direction and then in the other, then only the current flowing in one particular direction, determined by the bias of the diode, will flow. This effectively turns the current into a direct (DC) current.
Solar cells: In a solar cell, photons strike a diode, which shake free electrons (as in the photoelectric effect). These electrons are then accelerated through the electric field set up by the diode, and a current is established. In this way solar energy is being converted to electrical energy.
Light emitting diodes (LEDs): In a light emitting diode, as used for the display in a calculator or other electronic devices, a current established in a diode causes an electron to fill up a hole. In these devices such an occurrence can be thought of as a transition from a high energy state to a lower energy state. Just as in the Bohr model of the atom, the difference in energy between the two states is made up by the emission of a photon.