velocità motore step

Buongiorno a tutti,

sto utilizzando il seguente codice per far ruotare attraverso un telecomando il motore step 28BYJ-48 e il tutto sembra funzionare bene eccetto che la velocità del motorino è praticamente minima e tra l'altro singhiozza un po' quando lo faccio girare. Come posso aumentare la velocità e rendere più fluida la rotazione?

Ho provato anche ad aumentare o diminuire il valore di motorSpeed ma non è cambiato molto.

#include <IRremote.h>

//declare variables for the motor pins
int motorPin1 = 12;    // Blue   - 28BYJ48 pin 1
int motorPin2 = 11;    // Pink   - 28BYJ48 pin 2
int motorPin3 = 10;    // Yellow - 28BYJ48 pin 3
int motorPin4 = 9;    // Orange - 28BYJ48 pin 4
                        // Red    - 28BYJ48 pin 5 (VCC)

int motorSpeed = 1200;  //variable to set stepper speed
int count = 0;          // count of steps made
int countsperrev = 300;//512; // number of steps per full revolution
int lookup[8] = {B01000, B01100, B00100, B00110, B00010, B00011, B00001, B01001};
int volume = 0;

const int irReceiverPin =7; //the SIG of receiver module attach to pin7
const int ledPin = 13;//pin 13 built-in led

IRrecv irrecv(irReceiverPin); //Creates a variable of type IRrecv
decode_results results;

//////////////////////////////////////////////////////////////////////////////
void setup() {
  
  pinMode(ledPin,OUTPUT);//set ledpin as OUTPUT
  //Serial.begin(9600);//initialize serial
  irrecv.enableIRIn(); //enable ir receiver module
  
  //declare the motor pins as outputs
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
  Serial.begin(9600);
  Serial.println("OK"); //print"irCode: "
}

//////////////////////////////////////////////////////////////////////////////
void loop(){

if (irrecv.decode(&results)) //if the ir receiver module receiver data
  {
    Serial.print("-----> irCode: "); //print"irCode: "
    Serial.println(results.value, HEX); //print the value in hexdecimal
    //Serial.print("-----> irCodetutto: ");
    //Serial.println(results.value);
    //Serial.print(", bits: "); //print" , bits: "
    //Serial.println(results.bits); //print the bits

      if(results.value == 0xE0E0E01F)//if receiver module receive 0xFFA25D
      {
        digitalWrite(ledPin,HIGH);//turn on the led
        Serial.println(" accendi "); 

        volume++;
        if(volume < countsperrev )
          clockwise();
        else
          volume = countsperrev;
          
      }
      else if(results.value == 0xE0E0D02F)
      {
        digitalWrite(ledPin,LOW);//turn off the led
        Serial.println(" spegni "); 

        volume--;
        if(volume > 0)
          anticlockwise();
        else
          volume = 0;
      }
    
      irrecv.resume(); // Receive the next value
  }

  
  Serial.print("Volume: "); 
  Serial.println(volume); 
  /*if(count < countsperrev )
    clockwise();
  else if (count == countsperrev * 2)
    count = 0;
  else
    anticlockwise();
  count++;*/
}

//////////////////////////////////////////////////////////////////////////////
//set pins to ULN2003 high in sequence from 1 to 4
//delay "motorSpeed" between each pin setting (to determine speed)
void anticlockwise()
{
  for(int i = 0; i < 8; i++)
  {
    setOutput(i);
    delayMicroseconds(motorSpeed);
  }
}

void clockwise()
{
  for(int i = 7; i >= 0; i--)
  {
    setOutput(i);
    delayMicroseconds(motorSpeed);
  }
}

void setOutput(int out)
{
  digitalWrite(motorPin1, bitRead(lookup[out], 0));
  digitalWrite(motorPin2, bitRead(lookup[out], 1));
  digitalWrite(motorPin3, bitRead(lookup[out], 2));
  digitalWrite(motorPin4, bitRead(lookup[out], 3));
}

ad una rapida occhiata i problemi principali mi sembrano essere che tu invii una sequenza di 4 step al motore e poi ti perdi nel ciclo loop prima di inviarne altri, prova a togliere tutti i serial.print e dovrebbe accelerare un pochino, inoltre dovresti "fondere" il delay tra gli step insieme a tutto il resto, altrimenti non avrai mai un movimento fluido del motore

Prova di usare la libreria stepper compresa nel IDE.
Ciao Uwe

Mostraci uno schema dei collegamenti....