The device that converts mechanical energy into electrical energy is a generator.
Most generators work through electromagnetic induction. Mechanical energy turns a shaft, causing coils of wire and magnetic fields to move relative to one another. This changing magnetic environment induces an electric current in the coils, which can then flow through an external circuit and power electrical equipment.
British scientist Michael Faraday built the first electromagnetic generator, the Faraday disk, in 1831. Modern generators are commonly driven by steam turbines, gas turbines, water turbines, wind turbines, internal-combustion engines, or hand cranks. Large generators supply nearly all the electricity used on conventional power grids.
A turbine is not itself usually the electrical generator: it converts fluid motion into rotation that drives one. A transformer changes voltage, while a motor performs the reverse energy conversion, turning electrical energy into mechanical energy. In fact, many electric motors can operate as generators when their shafts are mechanically driven.