A commutator is a rotary electrical switch that periodically reverses the direction of the current between the rotor and the external circuit.