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

Yes, you are right. This code is taking 150 values and performing the average. The serial plotter is showing the same value in the power supply which shows the current in current sensor.