How does a LED

LED

 

Like any diode, the LED is a semiconductor composed of two layers of material juxtaposed with opposite electrical characteristics.  
Under the effect of a potential difference applied between the two layers, electrons penetrate into the layer   N-type, at the same time with an injection of holes in the P-type layer 
 
At the interface between these two areas, the electrons and holes, release energy in the form of photon by recombining. The nature and quality of materials used in the LED will define the wavelengths emitted by the photon . There is light emitting   when the photon wavelengths are performed in the visible.