PID or auto correcting turn system help

Here is a document by George Gillard that goes over the basics of a PID control loop with pseudocode

And here is an example P loop in vexcode c++