Problems with Arduino PID tuning on DC motor
The first thing that jumps out from your plot is the large and somewhat random variations in successive iterations.  That means you're not running the PID loop fast enough.  For something like a motor, every 5 to 10 ms (100-200 Hz) is probably good, but of course that depends on the motor.  Typically you want 20 to 50 iterations within the first major time constant of the system.

Only after the loop is running fast enough does tuning make any sense.

Start with just the P term, keeping I and D at 0.  Crank up P to just below where it causes ringing.  Now slowly bring up the I term.  This will cause oscillations when too high.  Find a value that sortof works, and tweak the P term again, etc.  Find a set of P,I values that work.

Often you stop there, since using the D term makes the system very susceptible to noise.  If your feed back signal is clean then start with the good P and I values, and slowly increase D.  On some systems D is actually negative to be useful.  Look at the math of your implementation carefully to see which polarity to use.

Think of the D term logic as "We're already heading in the right direction, so back off the drive a bit".  This can be useful to dampen things so that the other terms can be set more aggressively and you therefore get faster overall step response to within some error.