How do I write a PID loop to ctrl speed of DC Motor back to angle 0?

Using an IMU as my sensor and my error is obviously the current angle from 1 to 10 & -1 to -10. I am using a geared DC Motor. How would I be able to write the PID loop to control the speed of the motor until it hypothetically knows when that specific speed will hit angle 0? And yes, I got most of the fixins' wired up like the H-bridge and a pot for testing.

You have the project on the desk in front of you. We don't. NOTHING IS OBVIOUS. Even up and down are not obvious unless you explain it with words or pictures.

PID control is 90% P. The other two elements are relatively unimportant. P control is also relatively easy. It only takes one line to multiply the input signal to get the output. Maybe 2 or 3 lines depending on how the H bridge direction is set.

Tuning a PID is easiest done if the system is inherently linear, which means its best to use synchronous
rectification mode in the H-bridge (though not essential) for position control.

The simple approach to tuning:

Start with I and D zero. Raise P until the system oscillates, then back off 20% or so.

Raise I carefully until oscillation, back off I 20% - if you leave I as zero the system will never settle
fully on target position especially under any load - therefore you need a little I in practice usually.

Raising D may allow P to be increased (for faster response/settling), but will add noise (mechanical jitter).

For all of this to work you need to sense position frequently enough and accurately enough, which means
an encoder of reasonable resolution, and a timer interrupt can be used for timely execution of the loop.

Note that backlash in the gearing means that having the encoder on the gear box output will not allow
as rapid control as having encoder on the motor shaft. Encoder on the motor typically can be lower resolution
and thus cheaper.