SMM2:
This topic has been very helpful, because I also am trying to understand PID :)

Now, I believe I understand that the desired setpoint for a self-balancing robot is upright (90 degrees), and the input is the current angle that the robot is at.

I have my balancing bot maintain a setpoint of zero and use a signed int to see if it is falling +- X° from vertical. to get this I do have n offset adjustment to correct for the gyro not being mounted perfectly level

I plan on doing a line-follower robot soon, and I'm somewhat confused about the desired setpoint and input of the robot. I get that the desired setpoint would be the robot centered above the line(following the line), and the input is what the IR sensors read. Though, what confuses me is since the set point and input in the code are stored as numbers (as what I've understood), what would be the values for the desired set point and input for a line follower robot?

Any help would be great. :)

You are working with Yaw on the line following robot instead of pitch. Now your sensor will be receiving a value representing the line now most line following robots only follow the edge of the line and keep the sensor only on the left or right side of the line. Your setpoint should be about 50% of the value from black to white.
You will need to have a way to tell if you hop over the line on accident to keep your bot from loosing the line.

Lets say if your reading range is 0 ~ 100 and the ideal line position is 50. My first recommendation is to subtract 50 from the reading to get a new range of -50 ~ 50 with an ideal line potion of 0. This will solve several problems that you will face when the PID loops Starts.

Now lets look How PID works. Proportional is like a balancing scale if your Kp is set to 1 then a change of 10 on the input the output will change by 10. Now since the ideal line position is 0 you could start following the line with just proportional control. Integral slowly adds or subtracts from the output (you could say bending) the balancing scale bar to achieve setpoint. Integral is not needed because 0 is the ideal setpoint and having the default value for integral of Zero is ideal. Derivative allows for a quick reaction to change when the reading changes too fast (rate of change) the derivative will counter the change to prevent overshooting. Derivative will be a huge benefit when capturing the line. Too much Derivative your bot will be jittery too little and you bot will be sluggish when the line turns quickly.

Your PID setting could be something line this Kp=10 Ki=0 Kd=0.3 I would start with Kp first leaving Ki and Kd at 0. After Kp can follow a line without Ki or Kd you should start next with Kd and start with .1 or even smaller if .1 causes Shaking. again Ki isn't necessary because you have shifted the reading by -50 to make the ideal line following setpoint of Zero.

Z