Written for the Arduino by Brett Beauregard.
http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/
Additional explanation of functions on arduino site and the code is current on gitHub.
The more robust algorithm addresses common issues in response like target values going out of output range.