How to control a servo motor using a PID control with input from current sensor. I am not so proficient in arduino and in coding so can anyone please help me. I want to create a closed loop using pid for controlling servo with current sensor acs70331

Why average so many (150) samples? I think you are way past the point of diminishing returns (the point at which increasing the number of samples does not result in any improvements). It will just slow down the response unnecessarily.