# Possible Code Issue?

**URL:** <https://forum.arduino.cc/t/possible-code-issue/1407162>\
**Category:** Programming\
**Created:** [September 22, 2025, 1:27pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162 "2025-09-22T13:27:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![geoffplc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/geoffplc/32/1238030_2.png) [@geoffplc](https://forum.arduino.cc/u/geoffplc)\
**Post date:** [September 22, 2025, 1:27pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/1 "2025-09-22T13:27:50Z")

</div>

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

```arduino
#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

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [September 22, 2025, 1:31pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/2 "2025-09-22T13:31:12Z")

</div>

Welcome to the forum

Please post a schematic of your project showing how the components are connected and powered. The majority of problems with servos come down to how they are powered

---

<div class="post-metadata">

**Author:** ![geoffplc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/geoffplc/32/1238030_2.png) [@geoffplc](https://forum.arduino.cc/u/geoffplc)\
**Post date:** [September 22, 2025, 1:51pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/3 "2025-09-22T13:51:29Z")

</div>

![IMG_20250923_0047261](https://europe1.discourse-cdn.com/arduino/original/4X/e/3/8/e38ae3564d43b3ce49a4a91f4bc11cad0c2db2fa.jpeg)  
 ![IMG_20250923_0048001](https://europe1.discourse-cdn.com/arduino/original/4X/9/9/4/994114092a2963b65f439f4f73f5b139e188a2b7.jpeg)

Sorry don't have a schematic drawn up - but hope the photos will suffice

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [September 22, 2025, 1:59pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/4 "2025-09-22T13:59:41Z")

</div>

I am sorry, but it is impossible from your photographs to tell how the servos and the servo board are powered.

The schematic does not have to be fancy. A photo of a hand drawn circuit is good enough

---

<div class="post-metadata">

**Author:** ![geoffplc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/geoffplc/32/1238030_2.png) [@geoffplc](https://forum.arduino.cc/u/geoffplc)\
**Post date:** [September 22, 2025, 2:13pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/5 "2025-09-22T14:13:09Z")

</div>

![Screenshot 2025-09-23 020303](https://europe1.discourse-cdn.com/arduino/original/4X/2/2/b/22b49532ff8c09e84bf8346d10a769fc35709d1b.png)

Same as this - but with 5 Servo's  
Thankyou for replying to my post btw, and the welcome

---

<div class="post-metadata">

**Author:** ![camsysca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/camsysca/32/1015228_2.png) [@camsysca](https://forum.arduino.cc/u/camsysca)\
**Post date:** [September 22, 2025, 2:15pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/6 "2025-09-22T14:15:40Z")

</div>

First step - is the board address the same as the default address in the code? Run the I2C sniffer(it's in the xamples in the IDE), see if the board can be seen, and at what address.

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [September 22, 2025, 2:25pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/7 "2025-09-22T14:25:47Z")

</div>

> [@geoffplc](#):
>
> Same as this - but with 5 Servo's

What type of servos? The servo power supply should be rated for at least 1 Ampere per servo (for small ones like SG90), and 2.5 Amperes/servo for larger ones like the MG996R.

So, 6V at 5 Amperes, or 30 watts, absolute minimum.

For a robotic arm, 12 Amperes is the more likely requirement, which the traces on a single PCA9685 board probably can't handle.

If you look through this forum, this is a very common question. The vast majority of servo problems are due to inadequate servo power supplies.

---

<div class="post-metadata">

**Author:** ![geoffplc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/geoffplc/32/1238030_2.png) [@geoffplc](https://forum.arduino.cc/u/geoffplc)\
**Post date:** [September 22, 2025, 2:36pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/8 "2025-09-22T14:36:16Z")

</div>

I'm using MG996R  
Yes correct - I was concerned not enough amperage. I tested each servo individually and they all work, but as you say - Load might be the issue. Although I have to also wonder though - the program itself is set to run each servo separately in sequential step through, not more than one servo as it steps through the program. So is this still an issue???

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [September 22, 2025, 2:37pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/9 "2025-09-22T14:37:34Z")

</div>

> [@geoffplc](#):
>
> I tested each servo individually and they all work,

Was that with the sketch that you posted ?

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [September 22, 2025, 2:38pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/10 "2025-09-22T14:38:25Z")

</div>

> [@geoffplc](#):
>
> Load might be the issue.

Not really. Brushed DC motors briefly draw the stall current (2.5 A for the MG996R) every time they start moving, even when not loaded. Load exacerbates the problem, of course.

For that arm, you will need a power supply capable of delivering about 70 watts at 6V.

---

<div class="post-metadata">

**Author:** ![geoffplc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/geoffplc/32/1238030_2.png) [@geoffplc](https://forum.arduino.cc/u/geoffplc)\
**Post date:** [September 22, 2025, 2:39pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/11 "2025-09-22T14:39:18Z")

</div>

No - it was another one from the Arduino library for running a single servo off the Arduino Uno board only

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [September 22, 2025, 2:41pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/12 "2025-09-22T14:41:49Z")

</div>

Disconnect all but one of your servos and try the sketch. Does that one servo move ? If so, ad a second one and so on

---

<div class="post-metadata">

**Author:** ![geoffplc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/geoffplc/32/1238030_2.png) [@geoffplc](https://forum.arduino.cc/u/geoffplc)\
**Post date:** [September 22, 2025, 2:46pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/13 "2025-09-22T14:46:33Z")

</div>

Ok - might have to hook this up to my Bench power supply 0-30vdc at 5amps max  
That's all I can try because I don't have anything else with bigger amperage.  
But it's funny seeing videos of these robotic arms on youtube running with 6 volt power packs with no issues

---

<div class="post-metadata">

**Author:** ![geoffplc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/geoffplc/32/1238030_2.png) [@geoffplc](https://forum.arduino.cc/u/geoffplc)\
**Post date:** [September 22, 2025, 2:48pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/14 "2025-09-22T14:48:48Z")

</div>

No it doesn't work - I tried that

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [September 22, 2025, 2:50pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/15 "2025-09-22T14:50:30Z")

</div>

Did you check the I2C address as suggested earlier in the topic ?

---

<div class="post-metadata">

**Author:** ![geoffplc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/geoffplc/32/1238030_2.png) [@geoffplc](https://forum.arduino.cc/u/geoffplc)\
**Post date:** [September 22, 2025, 2:53pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/16 "2025-09-22T14:53:05Z")

</div>

I can't quite get my head around the addressing thing head. But I do know the program is communicating through the usb port with the board - it's flashing away with the LEDS when uploading to the Arduino

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [September 22, 2025, 2:56pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/17 "2025-09-22T14:56:37Z")

</div>

The I2C protocol is used to communicate between the Uno and the servo board. The latter has an address which must be used by your sketch otherwise communication between the boards will not work

Leave your circuit as it is and run the I2C scanner example from the Wire library. What, if anything, does it report ?

---

<div class="post-metadata">

**Author:** ![geoffplc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/geoffplc/32/1238030_2.png) [@geoffplc](https://forum.arduino.cc/u/geoffplc)\
**Post date:** [September 22, 2025, 3:02pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/18 "2025-09-22T15:02:43Z")

</div>

What does it report

You mean in the output box?

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [September 22, 2025, 3:05pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/19 "2025-09-22T15:05:03Z")

</div>

In the Serial monitor of the IDE

---

<div class="post-metadata">

**Author:** ![geoffplc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/geoffplc/32/1238030_2.png) [@geoffplc](https://forum.arduino.cc/u/geoffplc)\
**Post date:** [September 22, 2025, 3:10pm UTC](https://forum.arduino.cc/t/possible-code-issue/1407162/20 "2025-09-22T15:10:14Z")

</div>

Serial.print("I2C device found at address 0x");  
Serial.print(address, HEX);  
Serial.print("Unknown error at address 0x");  
Serial.println("No I2C devices found\n");

[Next page](https://forum.arduino.cc/t/possible-code-issue/1407162.md?page=2)
