How does an oscillator work?

An oscillator works in different ways in different electronic equipment. For example, there is a quartz oscillator in a quartz watch that can keep track of the time. A pendulum of a clock is an oscillator that goes back and forth using potential and kinetic energy.