Energy needs to move back and forth from one form to another for an oscillator to work. You can make a very simple oscillator by connecting a capacitor and an inductor together. If you've read How Capacitors Work and How Inductors Work, you know that both capacitors and inductors store energy. A capacitor stores energy in the form of an electrostatic field, while an inductor uses a magnetic field.
Imagine the following circuit:
If you charge up the capacitor with a battery and then insert the inductor into the circuit, here's what will happen:
- The capacitor will start to discharge through the inductor. As it does, the inductor will create a magnetic field.
- Once the capacitor discharges, the inductor will try to keep the current in the circuit moving, so it will charge up the other plate of the capacitor.
- Once the inductor's field collapses, the capacitor has been recharged (but with the opposite polarity), so it discharges again through the inductor.
This oscillation will continue until the circuit runs out of energy due to resistance in the wire. It will oscillate at a frequency that depends on the size of the inductor and the capacitor.