I have been working on a project that uses the Arduino to drive servo motors based on bytes it receives over the serial port from Processing. The prototype I had going was working well with 12 motors and 1 Arduino Uno, but the complete project is supposed to contain 30 servos. So I got a Mega, wired everything up, but the breadboards I was using to distribute the power started smoking when I hooked up the supply . So I went for 2 Adafruit 16 Channel PWM/Servo shields to do the power distribution (I now have a 5V 10A supply for each shield with a capacitor added as well), but I have been running into a problem with the transfer of information. I remapped all the values coming from Processing to fall within the PWM range of the servos since the Adafruit library drives them in this way, but when I watch the values come in on the Serial monitor on the Arduino side, they do not match up at all to what is coming out of Processing. I realized that this may be a data type issue, as the numbers coming from Processing are floating point, but I am having difficulty understanding the problem since I did not run into this before trying the shields. Wondering if anyone can shed some light on this in any way? I am at a bit of a dead end.
The motors are Hextronik HTX900's. I already posted on the Adafruit forum, but since it is a code issue rather than hardware I am not getting much help. I am using the pasted code to test one of the shields. The first attached screenshot are the values coming out of Processing, the second screenshot are the values coming into the Arduino.
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm0 = Adafruit_PWMServoDriver(0x40);
//Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x41);
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
#define SERVOMINÂ 150
#define SERVOMAXÂ 600
#define SERVOCENTER 375
int nextServo = 0;
int servoAngles[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
void setup() {
Â
 pwm0.begin();
 pwm0.setPWMFreq(50); // Analog servos run at ~60 Hz updates
Â
 for (int i = 0; i < 15; i++)
 {
  pwm0.setPWM(i, 0, SERVOCENTER);
 }
Â
 Serial.begin(9600);
}
void loop() {
Â
Â
 if(Serial.available()){
 Â
  int servoAngle = Serial.read();
  servoAngles[nextServo] = servoAngle;
  nextServo++;
 Â
  if(nextServo > 15){
   nextServo = 0;
  Â
  }
 Â
 Â
  pwm0.setPWM(0, 0, servoAngles[0]);
  pwm0.setPWM(1, 0, servoAngles[1]);
  pwm0.setPWM(2, 0, servoAngles[2]);
  pwm0.setPWM(3, 0, servoAngles[3]);
  pwm0.setPWM(4, 0, servoAngles[4]);
  pwm0.setPWM(5, 0, servoAngles[5]);
  pwm0.setPWM(6, 0, servoAngles[6]);
  pwm0.setPWM(7, 0, servoAngles[7]);
  pwm0.setPWM(8, 0, servoAngles[8]);
  pwm0.setPWM(9, 0, servoAngles[9]);
  pwm0.setPWM(10, 0, servoAngles[10]);
  pwm0.setPWM(11, 0, servoAngles[11]);
  pwm0.setPWM(12, 0, servoAngles[12]);
  pwm0.setPWM(13, 0, servoAngles[13]);
  pwm0.setPWM(14, 0, servoAngles[14]);
  pwm0.setPWM(15, 0, servoAngles[15]);
 Â
 Â
  }
 Â
 Â
Â
}