The piston mechanism is used to convert between rotary motion and reciprocating motion, it works either way. Driving the wheel will move the piston back and forth, in this form the piston can be used to pump liquids for example creating the high pressure need in a good coffee machine.
Alternatively the piston can be driven back and forth commonly by steam (in a steam engine) or flame (in a petrol engine). In this form the piston is used to convert reciprocating motion into more useful and usable rotary motion.
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.
You can download and make your own working piston mechanism here and find out how it works first hand.
I created this animation using Adobe Edge. Edge is a new tool for creating HTML 5 animations - much more standards compliant than Flash. It is currently a free download from Adobe LabsI have put the animation up without a Flash alternative to see how it goes. I'd be grateful to hear feedback about if it works for you. If possible please could you also let me know your operating system and browser.
Thanks!(Just to be clear, there should be an animation showing a piston working just above the picture of the crank mechanism project)