This thermal motion causes the electron clouds of the atoms to move back and forth resulting in the creation of electromagnetic waves. These waves will be very low frequency and low energy at very low temperatures and high frequency and high energy at high temperatures. The peak of this spectral energy distribution is an absolute measure of the radiating objects temperature. A second method that matter can use to produce electromagnetic waves is the fact that the electrons in atoms may exist at different energy levels. Only the lowest of the levels, know as the ground state is absolutely stable.
Most atoms are therefore in the ground state most of the time.
However, electrons my be knocked into a higher state if the atom absorbs some energy from its environment. This may be due to a collision with an other atom, or even by the absorption of just the right wavelength of light. Since this higher, or excited state is only meta-stable, it will decay after a short interval of time. When the electron decays back to a lower energy state, it must loose the energy equivalent to the difference in the energy of the two states. This is done by emitting the energy as a quick pulse of light of just the appropriate wavelength.