This mechanism is used to convert between rotary motion and reciprocating motion, it works either way. Notice how the speed of the piston changes. The piston starts from one end, and increases its speed. It reaches maximum speed in the middle of its travel then gradually slows down until it reaches the end of its travel.
Make your own here here.