Though it's long been rumored that step motors are driven by tiny hamsters on wheels contained inside, I can assure you that this is not only untrue, but also promulgated by unscrupulous pneumatic actuator salesmen. So how does a step motor work? In reality, step motors operate by electromagnetism. Specifically, a permanent magnet rotor such as the one shown below is attracted to electromagnets that reside in the stator. Observe that the rotor teeth on the front of the rotor are offset from those on the back. Between the two rotor halves is a strong permanent magnet that ensures all the teeth on the front of the rotor are magnetic north while those on the back are south poles. Remember this; you'll be tested later.
When electromagnetic stator coils are connected to a suitable step motor driver, the motor's position, velocity and acceleration can be precisely controlled without any need for feedback. Such simplicity is the reason step motors are a hallmark of the automation industry. If the driver energizes phase A such that two coils are magnetic north and the other two are south, while phase B is off, the rotor aligns as shown below. Notice that the rotor teeth align to the stator teeth of the top and bottom coils.
On the back side of the motor, the rotor teeth are offset, and align to the south stator teeth which are currently being repelled on the front of the motor.
We can force the rotor to the next position by turning off the current to phase A and applying current to phase B as we see below.
To proceed to the next full step position, we turn off phase B and energize the coils of phase A oppositely, so that the top and bottom stator teeth are south and the side teeth are north.
To get to the final position, we turn off phase A and energize phase B in reverse.
If you command the driver to move the motor at a constant speed, this is what you get: