a generator converts mechanical energy into electrical energy.

The modern-day generator works on the principle of electromagnetic induction discovered by Michael Faraday in 1831-32. Faraday discovered that the above flow of electric charges could be induced by moving an electrical conductor, such as a wire that contains electric charges, in a magnetic field. This movement creates a voltage difference between the two ends of the wire or electrical conductor, which in turn causes the electric charges to flow, thus generating electric current.