Robotic Arm help, Lynxmotion AL5D from RobotShop

Hello, I am a high school student currently working on a project where my partner and I are coding and attaching a robotic arm to a wheelchair and coding it to help medically disabled people perform normal tasks. I am running into issues where the servo motors I am using (recommended by RobotShop) are not responding to the code that I am uploading.

Here is the code that I am trying to upload.

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

  int baseServoPosition = 0;
  int shoulderServoPosition = 0;
  int elbowServoPosition = 0;
  int wristServoPosition = 0;
  int gripperServoPosition = 0;
  
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);

void setup() 
{
  pwm.begin();
  pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
}

void loop()
{
   grabbingBrush();
}
  

void grabbingBrush()
{
  
    for(int pulseLength = 0; pulseLength < 100; pulseLength++)//rotate towards the brush
  {
    pwm.setPWM(0,0,pulseLength);
  }
  delay(5000);
    for(int pulseLength1 = 0; pulseLength1 < 100; pulseLength1++)//bring the arm down
  {
    pwm.setPWM(1,0,pulseLength1);
  }
    delay(5000);

     for(int pulseLength2 = 0; pulseLength2 < 100; pulseLength2++)//bring the arm down
  {
    pwm.setPWM(2,0,pulseLength2);
  }
    delay(5000);

     for(int pulseLength3 = 0; pulseLength3 < 100; pulseLength3++) //need confirmation on number in middle
  {
    pwm.setPWM(3,0,pulseLength3);
  }
    delay(5000);

     for(int pulseLength4 = 0; pulseLength4 < 100; pulseLength4++)
  {
    pwm.setPWM(4,0,pulseLength4);
  }
  delay(10000);
}

I am adapted and changed the tutorial code found at the AdaFruit website to make this program. Thank you for any help that anyone can give!
Links:
http://www.robotshop.com/en/lynxmotion-al5d-robot-arm-hardware-4dof.html <— Robotic arm from Robotshop
http://arduino.cc/en/Main/ArduinoBoardUno <— Arduino Board
http://www.adafruit.com/products/1411 <— Shield that I am using.

I am running into issues where the servo motors I am using (recommended by RobotShop) are not responding to the code that I am uploading.

What are they doing, if anything ?
How are they wired ?
How are they powered ?

UKHeliBob:

I am running into issues where the servo motors I am using (recommended by RobotShop) are not responding to the code that I am uploading.

What are they doing, if anything ?
How are they wired ?
How are they powered ?

  1. They are not doing anything
  2. They are wired into the shield's 3 prong connectors. It is made for the servo's to be plugged into.
  3. They are powered by a 9v battery

From your code

    for(int pulseLength = 0; pulseLength < 100; pulseLength++)//rotate towards the brush

From the example for the library

#define SERVOMIN  150 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX  600 // this is the 'maximum' pulse length count (out of 4096)
  for (uint16_t pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++)

I would conclude that the pulse length never gets long enough in your code to make the servos run. Change the range of the for loop so that its starts at 150 and ends at 600 and report back.

I tried the change you suggested, changing pulseLength to 150, and setting the loop to end at 600; yet the motors still did not move.

Have you tried running the example from the library ?

Yes, the example does not work either.

Is there any reason why you are not driving the servos directly from the Arduino using the servo library (using external power) rather than using that shield ? What servos are you using ?

  1. They are powered by a 9v battery

What kind of 9V battery? A smoke detector type? If so, no wonder the servos aren't moving.