How can a diode produce light?
When current flows across a diode, negative electrons move one way and positive holes move the other ways.
The holes exist at a lower energy level than the free electrons, so when a free electron falls it loses energy.
This energy is emitted in the form of a light photon. The size of the electron’s “fall” determines the energy level of the photon, which determines its Colour. A bigger fall produces a photon with a higher energy level and therefore a higher light frequency.