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

You code does not take 150 values and average them.

for( 1 = 1; i<151; i++)
{
AcsValue = analogRead(A0);
Samples = Samples + AcsValue; //Add samples together
delay (3); // let ADC settle before next sample 3ms
}
AvgAcs=Samples/150.0;//Taking Average of Samples

That takes 150 samples and averages them.

1 Like