Increasing servo motor speed

Hi. I'm controlling a servo motor? I want the servo rotate faster. I commented the delay but it's slow yet. How can I increase it's speed?
This is the sketch:

#include <SoftwareSerial.h>
#include <Servo.h>
#include "HCPCA9685.h"

SoftwareSerial BT(13,12);  //RX , TX pins

char state=0;
/* I2C slave address for the device/module. For the HCMODU0097 the default I2C address
is 0x40 */ 
#define  I2CAdd_1 0x40
#define  I2CAdd_2 0x41

int pos1 = 200;
int pos2 = 220;
int pos3 = 180;
int pos4 = 0;
int pos5 = 130;
int pos6 = 100;
int pos7=50;
int pos8=260;
int pos9=140;
int delay1;
int delay2 = 500;

/* Create an instance of the library */
HCPCA9685 HCPCA9685_1(I2CAdd_1);
HCPCA9685 HCPCA9685_2(I2CAdd_2);

void setup() {
  /* Initialise the library and set it to 'servo mode' */

  // Initialise both modules
  HCPCA9685_1.Init(SERVO_MODE);
  HCPCA9685_2.Init(SERVO_MODE);

  // Wake both devices up
  HCPCA9685_1.Sleep(false);
  HCPCA9685_2.Sleep(false);

  unsigned int Pos;
  
  for (int Pos = pos4; Pos < pos6; Pos++)
  {
    HCPCA9685_1.Servo(2, Pos);
   //delay(0);
  }
}

void loop() {

}

Let me see. Hmm. Adding 1 every time through the loop. What might happen if you add 3 instead?

Hint. Pos ++++++ won't do it.

1 Like

How can I add 3?

If you were a student, you'd probably be arrested for criminal neglect...of a textbook. Seriously?
How do you add 3 to any variable?
Pos = Pos + 3; look familiar?

4 Likes

I tested but the servo didn't move.

#include <SoftwareSerial.h>
#include <Servo.h>
#include "HCPCA9685.h"

SoftwareSerial BT(13,12);  //RX , TX pins

char state=0;
/* I2C slave address for the device/module. For the HCMODU0097 the default I2C address
is 0x40 */ 
#define  I2CAdd_1 0x40
#define  I2CAdd_2 0x41

int pos1 = 200;
int pos2 = 220;
int pos3 = 180;
int pos4 = 0;
int pos5 = 130;
int pos6 = 100;
int pos7=50;
int pos8=260;
int pos9=140;
int delay1;
int delay2 = 500;

/* Create an instance of the library */
HCPCA9685 HCPCA9685_1(I2CAdd_1);
HCPCA9685 HCPCA9685_2(I2CAdd_2);

void setup() {
  /* Initialise the library and set it to 'servo mode' */

  // Initialise both modules
  HCPCA9685_1.Init(SERVO_MODE);
  HCPCA9685_2.Init(SERVO_MODE);

  // Wake both devices up
  HCPCA9685_1.Sleep(false);
  HCPCA9685_2.Sleep(false);

  unsigned int Pos;
  
  for (int Pos = pos4; Pos < pos6; Pos+3)
  {
    HCPCA9685_1.Servo(2, Pos);
   //delay(0);
  }
}

void loop() {

}

I give up. Try this.

for (int Pos = pos4; Pos < pos6; Pos = Pos + 3)

1 Like

@alija22 This topic is (again) on the same subject as another of your topics.

What speed does it go now?

@alija22
You've got better help now, so I set you back to 'ignore'. Too much work. 'Bye!

2 Likes

no this is different. Think about differences just for a minute

I don't know but I guess about 60 degrees per one 0.5 second. while in the servo catalog it's 60 degrees per 0.2 second

I tested it. the servo works but there are no changes in the speed.

what does this do?

It what?

Post the complete sketch that works, has the stuff you are shown, and shown again correcting your first apprehension and fails.

You've done something wrong or your issue is elsewhere.

a7

servo rotates 3 steps each time

#include <SoftwareSerial.h>
#include <Servo.h>
#include "HCPCA9685.h"

SoftwareSerial BT(13,12); //RX , TX pins

char state=0;
/* I2C slave address for the device/module. For the HCMODU0097 the default I2C address
is 0x40 */
#define I2CAdd_1 0x40
#define I2CAdd_2 0x41

int pos1 = 200;
int pos2 = 220;
int pos3 = 180;
int pos4 = 0;
int pos5 = 130;
int pos6 = 100;
int pos7=50;
int pos8=260;
int pos9=140;
int delay1;
int delay2 = 500;

/* Create an instance of the library */
HCPCA9685 HCPCA9685_1(I2CAdd_1);
HCPCA9685 HCPCA9685_2(I2CAdd_2);

void setup() {
/* Initialise the library and set it to 'servo mode' */

// Initialise both modules
HCPCA9685_1.Init(SERVO_MODE);
HCPCA9685_2.Init(SERVO_MODE);

// Wake both devices up
HCPCA9685_1.Sleep(false);
HCPCA9685_2.Sleep(false);

unsigned int Pos;

for (int Pos = pos4; Pos < pos6; Pos=Pos+3)
{
HCPCA9685_1.Servo(2, Pos);
//delay(0);
}
}

void loop() {

}

right. does it turn faster now?

Hi, @alija22

What is your project?
Why do you need fast servo movement?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Looks a Braccio robot arm by the "degree stops." Combining with a BT control of the servos.