Heading control with PID

The compass can be used to determine the heading, but it unfortunately won't work "out of the box" and must be calibrated. Here is a great overview on how to do that.