-1

I'm trying to control my 180 degree servo motors through a Adafruit 1411 Servo shield. However I don't find it simple enough to write the servo's position in angles like the normal servo library without the shield.

Using the Adafruit 1411 Servo shield and Adafruit_PWMServoDriver-library lets you control a servomotor by modifying its pulselength as far as I've realised. To my question..

Is there a way for me to either use the servo shield's output and still write in degrees OR somehow convert these pulselength into angle-degree?

Example of the differences:

Adafruit_PWMServoDriver-library:

pwm.setPWM(Servo, 0, pulseLength);

Servo-library:

Servo.write(45); //Writing in angles like this would be optimal for my project.

Any help in the right direction is much appreciated!

ryyker
  • 22,849
  • 3
  • 43
  • 87
Arnoldy14
  • 3
  • 1
  • Have you already tried anything in code? If so, post it. If not, this question really has nothing to do with the C tag. (or any other language tag at this point.) – ryyker May 16 '19 at 12:30
  • How to do this is described in the tutorial for the product. See the bottom of this page: https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield/using-the-adafruit-library – Thomas Jager May 16 '19 at 12:31

1 Answers1

0

Use the Arduino map function. The following is from the Adafruit instructions:

pulselength = map(degrees, 0, 180, SERVOMIN, SERVOMAX);

Where SERVOMIN and SERVOMAX are values you set according to the range of travel of your servo. This linearly maps a value between 0 and 180 into the range between SERVOMIN and SERVOMAX.

Since you've been doing this with pulse widths so far, you probably already knew the values you need to use.

Thomas Jager
  • 4,836
  • 2
  • 16
  • 30