Read paper State Machine Design Pattern.

Browsed classical book PID controllers theory design and tuning.

Played with online PID control simulator allowing you to try out a PID controller interactively by adjusting the tuning parameters in realtime. Would be good task to port this into Swift.

Played with sandbox application where you can play with a basic, manually-tuned PID control loop.