mpmcws

PCA9685

Dec 26th, 2018
133
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // all servomotor 0 degree angle
  2. //by MCW 2018
  3. //public domain code GNU
  4. #include <Wire.h>
  5. #include "PCA9685.h"
  6. PCA9685 driver;
  7. PCA9685_ServoEvaluator pwmServo(100, 300, 500);
  8. void setup() {
  9.   Wire.begin();
  10.   Wire.setClock(400000);
  11.   driver.resetDevices();
  12.   driver.init(B000000);
  13.   driver.setPWMFrequency(50);
  14. }
  15. void loop() {
  16.   delay(500);
  17.   driver.setChannelPWM(1, pwmServo.pwmForAngle(0));
  18.   delay(500);
  19.   driver.setChannelPWM(2, pwmServo.pwmForAngle(0));
  20.   delay(500);
  21.   driver.setChannelPWM(3, pwmServo.pwmForAngle(0));
  22.   delay(500);
  23.   driver.setChannelPWM(4, pwmServo.pwmForAngle(0));
  24.   delay(500);
  25.   driver.setChannelPWM(5, pwmServo.pwmForAngle(0));
  26.   delay(500);
  27.   driver.setChannelPWM(6, pwmServo.pwmForAngle(0));
  28.   delay(500);
  29.   driver.setChannelPWM(7, pwmServo.pwmForAngle(0));
  30.   delay(500);
  31.   driver.setChannelPWM(8, pwmServo.pwmForAngle(0));
  32.   //....
  33. }
RAW Paste Data