Hi,
I am using an Adafruit 16ch pwm Servo Controller and now I need to add more controllers. I am pretty happy with how to set up controller addressing but I can't find how to issue commands to servos on different controllers.
With one controller, the command to a servo is:
pwm.setPWM(15, 1024, 3072) where 15 is servo 15, 1024 is pwm signal rise time and 3072 pwm signal fall time.
How do I give commands to servos attached to different controllers?
Thanks in advance,
mmmbeeer
I had better add I'm using an Arduino Mega 2560 to drive the controller.
Multiple Adafruit 16ch pwm Servo Controllers
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: Multiple Adafruit 16ch pwm Servo Controllers
You declare an instance of Adafruit_PWMServoDriver for each board and specify the address:
You will need to initialize all instances as well:
Then you can send commands to the first board by referencing the first instance by name and to the second board by referencing the second instance by name.
Code: Select all
Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x40);
Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x41);
Code: Select all
pwm1.begin();
pwm2.begin();
pwm1.setPWMFreq(60); // Analog servos run at ~60 Hz updates
pwm2.setPWMFreq(60); // Analog servos run at ~60 Hz updates
Code: Select all
pwm1.setPWM(n, 0, pulse);
pwm2.setPWM(n, 0, pulse);
-
- Posts: 2
- Joined: Sat Feb 08, 2014 8:11 am
Re: Multiple Adafruit 16ch pwm Servo Controllers
Thanks indeed for that adafruit_support_bill, it is much appreciated.
Regards,
mmmbeeer
Regards,
mmmbeeer
Please be positive and constructive with your questions and comments.