The P type semiconductor is connected with the positive end of battery and N type with the negative end of the battery. When a current is passed through the LED, free electrons from the N layer moves to the P layer in the active region (P-N Junction). This involves a drop from the conduction band to the lower orbit and electrons release some energy in the form of photons. The frequency and wavelength of the light produced photons is dependent on the material and doping level of the semiconductor. In case of LED, the material used and doping levels are set so as to produce photons with wavelength in the range of desired color of light in the visible spectrum.
Light Emitting Diodes are made from exotic semiconductor compounds such as Gallium Arsenide (GaAs), Gallium Phosphide (GaP), Gallium Arsenide Phosphide (GaAsP), Silicon Carbide (SiC) or Gallium Indium Nitride (GaInN) all mixed together at different ratios to produce a distinct wavelength of colour. Different LED compounds emit light in specific regions of the visible light spectrum and therefore produce different intensity levels. The exact choice of the semiconductor material used will determine the overall wavelength of the photon light emissions and therefore the resulting colour of the light emitted.
How to calculate the value of the Series Resistor for an LED?