#include <Servo.h>

int pot1;
int pot2;

float pot1Scaled;
float pot2Scaled;

float pot1Smoothed;
float pot2Smoothed;

float pot1SmoothedPrev;
float pot2SmoothedPrev;

Servo servo1;
Servo servo2;


void setup() {

  pinMode(A0, INPUT);
  pinMode(A1, INPUT);

  Serial.begin(115200);

  servo1.attach(4);
  servo2.attach(5);

  servo1.writeMicroseconds(1650);
  servo2.writeMicroseconds(1650);

}

void loop() {

  pot1 = analogRead(A0);
  pot2 = analogRead(A1);

  // scale all pots for the servo microseconds range

  pot1Scaled = (pot1 - 512) + 1500;
  pot2Scaled = (pot2 - 512) + 1500;

  // smooth pots

  pot1Smoothed = (pot1Scaled * 0.02) + (pot1SmoothedPrev * 0.98);
  pot2Smoothed = (pot2Scaled * 0.02) + (pot2SmoothedPrev * 0.98);

  // bookmark previous values

  pot1SmoothedPrev = pot1Smoothed;
  pot2SmoothedPrev = pot2Smoothed;

  Serial.print(pot1Smoothed);
  Serial.print(" , ");
  Serial.print(pot2Smoothed);
  Serial.println(" , ");

  // write servos

  servo1.writeMicroseconds(pot1Smoothed);
  servo2.writeMicroseconds(pot2Smoothed);

  delay(5);                      // run loop 200 times/second

}