Hello all,
So I'm an Electrical Automation Engineer. PLC's, Scada, HMI is my usual knowledge of Coding.
For fun I bought this kit off AliExpress 5 dof robotic arm that I've bought and put together with my 10 year old daughter.
I've watched a few youtube videos on these and picked up a code to upload and it uploaded fine - No errors but nothing happens
None of the servo's start moving.
Certainly no genius with this type of coding, would appreciate a little help
Here's my hardware
Arduino Uno
PCA 9685 PWM
Power Supply 6.0 vdc to PCA 9685
Downloaded the Adafruit pwm servo driver from the library
Found my Arduino board and com port
Everything fine there, I can see on the Arduino the program been loaded to the board by the LEDS through the com connection, but alas no movement from the servo's
Here is the code I've used
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
// Initialize the PCA9685 module with the default address (0x40)
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40);
// Define the PWM frequency for standard analog servos
#define SERVOFREQ 50
// Define the servo channels for each DOF
#define BASE_SERVO 0
#define SHOULDER_SERVO 1
#define ELBOW_SERVO 2
#define WRIST_SERVO 3
#define GRIPPER_SERVO 4
// Define the pulse width for minimum and maximum servo angles (0 and 180 degrees)
#define SERVOMIN 150 // Minimum pulse length (out of 4096)
#define SERVOMAX 600 // Maximum pulse length (out of 4096)
// Function to calculate the pulse length from an angle
int angleToPulse(int angle) {
return map(angle, 0, 180, SERVOMIN, SERVOMAX);
}
void setup() {
Serial.begin(9600);
pwm.begin();
pwm.setPWMFreq(SERVOFREQ); // Set the PWM frequency
// Wait for a second to allow the module to start
delay(1000);
// Center all servos to a neutral 90-degree position
pwm.setPWM(BASE_SERVO, 0, angleToPulse(90));
pwm.setPWM(SHOULDER_SERVO, 0, angleToPulse(90));
pwm.setPWM(ELBOW_SERVO, 0, angleToPulse(90));
pwm.setPWM(WRIST_SERVO, 0, angleToPulse(90));
pwm.setPWM(GRIPPER_SERVO, 0, angleToPulse(90));
}
void loop() {
// Example 1: Move all servos in a sequence
Serial.println("Moving servos to 0 degrees...");
for (int i = 0; i < 5; i++) {
pwm.setPWM(i, 0, angleToPulse(0));
delay(500);
}
Serial.println("Moving servos to 180 degrees...");
for (int i = 0; i < 5; i++) {
pwm.setPWM(i, 0, angleToPulse(180));
delay(500);
}
Thanks Geoff in New Zealand


