The rack and pinion is a special pair of gears. The rack looks like the outside of a spur gear that has been uncurled and laid flat. The pinion is the small spur gear that meshes with the rack.


Click here to see the video

When the pinion rotates, it makes the rack move back and forth. Or, if the rack moves back and forth, that makes the pinion rotate. So the rack and pinion turns rotational motion into straight line motion and vice versa.
Make sure the rack can slide freely with as little friction as possible. Lego tiles or the bottoms of beams are good surfaces to use.

See also: Gears, Cranks