Explanation
Electromagnetic waves are the combination of electric and magnetic field waves produced by moving charges.
The creation of all electromagnetic waves begins with a charged particle.
This charged particle creates an electric field (which can exert a force on other nearby charged particles).
When it accelerates as part of an oscillatory motion, the charged particle creates ripples, or oscillations, in its electric field, and also produces a magnetic field (as predicted by Maxwell’s equations).
Once in motion, the electric and magnetic fields created by a charged particle are self-perpetuating—time-dependent changes in one field (electric or magnetic) produce the other. Both electric and magnetic fields in an electromagnetic wave will fluctuate in time, one causing the other to change.
Electromagnetic waves (photons) are produced anytime a charged particle experiences a change in velocity.. The electromagnetic wave (radiation) that is produced when the charge particle changes it’s velocity is how energy is conserved. This energy is light.
A simple example of this is in the production of microwaves.
Inside of a microwave oven is a component called a magnetron. Inside the magnetron is a cavity which is like a circular race track for electrons. The electrons go around this little circular track at immense speeds. While they are running in the little circles at these very high speeds, a fluctuating magnetic field causes the electrons to wiggle back and forth towards the inside and outside of the race track. This wiggling happens at a high frequency and is what causes the generation of the microwaves.