Electric Motor Working Animation. Animated web version is here: How it works in practice.
Note how the commutator reverses the current each time the coil turns halfway. Advertisement the diagram shows how the commutator (in green) and brushes (in red) work together to let current flow to the electromagnet, and also to flip the direction that the electrons are flowing at just the right.