Stepper motor just vibrates, sometimes turns 20~45 degrees when varying speed

Hi all, I am using the stepper and controller included in an AliExpress starter kit. And I am using Tom Igoe's sample sketch "stepper_speedControl.ino", which just has a potentiometer for analog control of the commanded speed. https://www.arduino.cc/en/tutorial/stepperSpeedControl

The 5 colored wires from motor are pre-terminated with a white JST plug that only fits one way into the controller board. Rainbow ribbon was used to connect IN1, IN2, IN3, IN4 of the controller board to the UNO's digital pin 8,9,10,11 respectively.

Power supply to the controller was from a LiPo pack, I was able to vary the voltage from 1S to 3S, by poking into the balance plug of the LiPo pack, but the behavior was all the same.

Is it safe for me to just blindly shuffle the 4 digital connections in a trial and error manner?

|500x280 (right-click open-image-in-new-tab to view in full size) |469x500 |432x500

Ok, it works with the code provided by NikodemBartnik. https://github.com/NikodemBartnik/ArduinoTutorials https://www.youtube.com/watch?v=avrdDZD7qEQ It does not use Stepper.h

At first, I thought maybe Stepper.h is not compatible with the 28BYJ stepper motor, but then I found this guide by "Helen" which also works for me, and it does use Stepper.h , so huh. https://www.seeedstudio.com/blog/2019/03/04/driving-a-28byj-48-stepper-motor-with-a-uln2003-driver-board-and-arduino/

This works with my starter kit.

#include <Stepper.h>
#define STEPS 2038 // the number of steps in one revolution of your motor (28BYJ-48)
Stepper stepper(STEPS, 8, 10, 9, 11);
void setup() {
  Serial.begin(9600);
}
void loop() {
  int sensorReading = analogRead(A0);
  int motorSpeed = map(sensorReading, 0, 1023, -20, 20);
  Serial.println(String(sensorReading) + ", " + String(motorSpeed));
  stepper.setSpeed(abs(motorSpeed)); 
  if (motorSpeed != 0) {
    stepper.step(motorSpeed); 
  }
}

In the above hackish code, motorSpeed int variable serves multiple purposes, for direction, speed and step-count per loop.

I wouldn't assume all these 28BYJ's are wired the same. Those 4 wires for the windings can be in 24 different orders, only 8 or them will work with any particular sketch.