Arduino 3D printer sketch
[For now] most of the open source 3d printer firmware written for Arduino-based hardware. This means you can just download the source and look through the relevant pieces of code.

Marlin is the most obvious example.