A Stepper motor consists of multiple electromagnets arranged in a circle around a permanent magnet. When one of the electromagnets turns on, the permanent magnet moves to align with it. When the permanent magnet aligns with one electromagnet, it is called a full step. By turning on and off the electromagnets in the right sequence, the permanent magnet, which is coupled to the shaft of the motor, can move in steps clockwise and counterclockwise. The number of steps it takes for one resolution depends on the model of the stepper motor. The stepper motor can move infinitely in either direction.
The motor can also move to places in between two electromagnets by turning on two at the same time. This is called a half step.
In addition to half steps, there are also quarter, sixteenth, and even thirty-second steps, all of which are created by varying the strength of the magnetic field between two neighboring steps. Using smaller step sizes gives you more control over the motor’s movement at the expense of available torque and speed.
Real stepper motors don’t have just four full steps available. Instead, the most common value is 200 steps per revolution. They do this by winding the coils in a more complicated way than the simple diagrammatic ones shown above and by using cleverly designed mechanical teeth which steer the magnetic field precisely the way they want it to go. The following animation shows one flavor of stepper motor, which has four coils, going through four very small steps as the coils fire in sequence:
To use a stepper motor, you will usually need a stepper motor driver to be able to supply enough power to it.
Please see the Stepper Motor Driver page for starter code and connections.