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.

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?

(right-click open-image-in-new-tab to view in full size)

Ok, it works with the code provided by NikodemBartnik.

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.

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() {
void loop() {
  int sensorReading = analogRead(A0);
  int motorSpeed = map(sensorReading, 0, 1023, -20, 20);
  Serial.println(String(sensorReading) + ", " + String(motorSpeed));
  if (motorSpeed != 0) {

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.