#include <pwmWrite.h>

Pwm pwm = Pwm();

const int servoPin4 = 8;
const int servoPin5 = 9;
const int freq = 50; // Frequency in Hz (50 Hz is common for most hobby servos)

void setup() {
  Serial.begin(115200);
  // Set the frequency for timer 3, which corresponds to channel pair 4 and 5
  // pwm.attach(pin, ch, minUs, defUs, maxUs);
  pwm.attach(servoPin4, 4, 500, 1472, 2400);  // default is 50 Hz, using ch 4
  pwm.attach(servoPin5, 5, 500, 1472, 2400);  // default is 50 Hz, using ch 5

  // change servoPin4 frequency to 55 Hz. Channel pair 4 and 5 will both be 55 Hz
  // attach servoPin5 to a different ch pair for it to use a unique frequency.
  // pwm.setFrequency(servoPin4, 55); // comment out to use default 50Hz

  pwm.printDebug();  // check the status of all channels
}

void loop() {
  int position; // position in degrees
  for (position = 0; position <= 180; position += 30) {
    pwm.writeServo(servoPin4, position);
    pwm.writeServo(servoPin5, 180 - position);
    delay(1000);
  }
}