Building on the intuitive model presented in part 1, we take a look at the mathematical model and write a PID control loop based on that model. Hang in there if you're unfamiliar with the math... it turns out to be pretty straight-forward code in the end!
Like part 1, this is a first take. I was going to make a second take, but I discovered I had scribbled all over my only nice-looking copy of the PID math. Your comments are welcome!
The printed formula is from wikipedia. I tried doing this Khan Academy style with a tablet... wow that's hard to write with, that man is a genius if for no other reason being able to use one of those things!