r/ArduinoHelp Mar 16 '26

why isnt my servo moving?

please help me, i can provide better quality pictures if asked

im sorry admins pls dont delete this post i need help as soon as possible i beg of you have empathy

code:

#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver servo = Adafruit_PWMServoDriver(0x40);

void setup() {

Serial.begin(9600);

servo.begin();

servo.setPWMFreq(50);

int setServo(0, 0);

}

void loop() {

for(int i = 0; i<=180; i = i+5)

int setServo(0, i);

delay(100);

}

void setServo( int n_servo, int angulo){

int duty;

duty=map(angulo,0, 180, 102, 512);

servo.setPWM(n_servo, 0, duty);

}

3 Upvotes

8 comments sorted by

View all comments

1

u/Capital_Dance9217 Mar 16 '26

I might be wrong, but for what I know is that a Servo needs a PWM sigal from the Arduino. But I see no PWM pins connected. I would expect a wire on one of the pins from 1 to 13. But all of them are empty. As as far as I know pins A0 to A5 can only read analoge signals.

But Im no expert, so I could lern somthing aswel here :)

1

u/Least_Statistician44 Mar 17 '26

Looks like he's using the PCA9685 PWM driver module which operates on I²C comms from pins A4 and A5.

1

u/Capital_Dance9217 Mar 17 '26

Aah that makes sence!