A PID controller is a feedback control loop that calculates an error value as the difference between a setpoint and a measured variable in
a process.The PID controller minimizes the error by adjusting the input.
After an initial trial at the subject I developed a library and this project has to do with it. I don’t claim that the present library is the best around (cfr. Brett Beauregard PID library), but it fulfils the purpose and works. The sketch has a passive low pass filter and the PID loop works between its input and output until a stable state is achieved. The montage is trivial.
The initialization constructor allows to declare an object globally before the setup() function and to insert the PID settings.