Smoothing the servos?

Hey everyone,

First big shout out to the @paulpaulson. You helped me a lot mate and tnx for that.

The problem I’m now facing is the jittering motion of two servos. I’ve averaging or “smoothing” the signal from the EMG to the servos and it moves, but very jittery.

Please check out the code and the clip in the drive link, below.

Is there a way to use a ServoEasing lbr in the code or there might be a better way of doing the smoothing?

Again, any help would be incredibly appreciated for a total beginner like me!

did you check the usage of a Kalmanfilter to flatten the noise of the raw sensor data?

Hey @paulpaulson, yap but it was too much complicated for me to use. :slightly_frowning_face: :

That’s why I’m trying to find out an easier method to smooth out the servos.

An update!

I was able to find the new library for Arduino Smoothing. And added the piece of the code that does the actual analog smoothing, which turns out really well.

The next problem that I’m dealing with is how to duplicate the lines of the code, so that the analog smoothing goes for the second analog input, separately?

Any help is greatly appreciated!

show your actual sketch to see what happens.

Sure mate, sorry for that. Here it is:

#include <AnalogSmooth.h>
#include <Servo.h>
#define BTN 4

enum {Stage1, Stage2};
struct BUTTON {
byte pin;
byte pinmode;
bool state;
int stage;
unsigned long stamp;
unsigned long debounce;
} button {BTN, INPUT, 0, Stage1, 20, 20};

Servo myServo;
Servo myServo1;

int ServoPin = 6;
int ServoPin1 = 2;
int angle, angle1; // Create a variable called ServoPin

int EMG = A0;
int EMG1 = A1;

AnalogSmooth as100 = AnalogSmooth(100);

void setup() {
pinMode(, button.pinmode);


void loop() {

if (millis() - button.stamp >= button.debounce) {
button.stamp = millis();
bool state = digitalRead(;
if (button.state != state) {
button.state = state;
if (state) {
button.stage = button.stage % 2;

switch (button.stage) {
case Stage1:

case Stage2:

  float analogSmooth100 = as100.analogReadSmooth(EMG);
  angle = map(analogSmooth100, 420, 800, 70, 100);
  angle1 = map(, 200, 700, 50, 70);


You have to have a second instantiation of the analogSmooth class.

Hey @paulpaulson, sure I got that, but how to actually do it, since I tried with analogSmooth1 or AnalogSmooth1 and did not actually worked?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.