Stepper motor not moving though no error message

Hello, I'm currently repurposing my old kevin the minnion toy by disecting it and inserting an Arduino R3 UNO, a HC-SR04 ultrasonic sensor for avoiding obstacles, a ULN2003 Motor Driver Board and a 28BYJ-48 Stepper Motor to control side wheel one, a Breadbord power supply model connected to a 9v battery connecter transmitting power to the module via a 9v battery, a servo motor to control side wheel 2, and lastly a 3v DC motor in the back for stability. Honestly, I think this is a suitable beginner project to get me used to doing big projects without following any 1 specific video guide, but I'm open to listening if you disagree.

Till now, I have disected Kevin, connected the ultrasonic sensor, power supply module, 9v battery, 9v battery connecter, arduino, Motor Driver Board, and the stepper motor all together and managed to combine two different .ino files from github to make the code you can see below.

My issue here is that the stepper motor will not rotate even though they are no errors whatsoever. I tripled checked the pins and they are correctly arranged and what makes it even more weird is that the ultrasonic sensor is doing exactly what it needs to.

If you have any other concerns such as questioning if I can do it, giving me tips on what to use etc, feel free to post them I am very open to listening and I truly welcome it as I am new to engineering. Here are my components:

#define STEPPER_PIN_1 9
#define STEPPER_PIN_2 10
#define STEPPER_PIN_3 11
#define STEPPER_PIN_4 12
int step_number = 0;

long duration;
int distance;

const int trigPin = 6;
const int echoPin = 5;


void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  Serial.begin(115200);

  pinMode(STEPPER_PIN_1, OUTPUT);
  pinMode(STEPPER_PIN_2, OUTPUT);
  pinMode(STEPPER_PIN_3, OUTPUT);
  pinMode(STEPPER_PIN_4, OUTPUT);



  }

void loop() {


  OneStep(false);
  delay(2);

  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH, 20000); // 20ms timeout (~3.4m max)
  distance = duration * 0.034 / 2;

  
  Serial.println(distance); 
  delay(100);
  


}

void OneStep(bool dir){
    if(dir){
switch(step_number){
  case 0:
  digitalWrite(STEPPER_PIN_1, HIGH);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, LOW);
  break;
  case 1:
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, HIGH);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, LOW);
  break;
  case 2:
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, HIGH);
  digitalWrite(STEPPER_PIN_4, LOW);
  break;
  case 3:
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, HIGH);
  break;
} 
  }else{
    switch(step_number){
  case 0:
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, HIGH);
  break;
  case 1:
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, HIGH);
  digitalWrite(STEPPER_PIN_4, LOW);
  break;
  case 2:
  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, HIGH);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, LOW);
  break;
  case 3:
  digitalWrite(STEPPER_PIN_1, HIGH);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, LOW);
 
  
} 
  }
step_number++;
  if(step_number > 3){
    step_number = 0;
  }
}





// Thank you for your assistance.```

Hi, @newbiewilliam
Welcome to the forum.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

What are you using for the 9V power supply?

Please write some simple code that JUST tries to drive A stepper, nothing else.

You need to write your code in stages and get each input and output working separately before beginning to combine them.

For the moment forget about you code and write some trouble shooting code.

A schematic at this stage would be most welcome.

Do you have a DMM? Digital MultiMeter?

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

What's this?

Hello Tom, beforehand, I want to thank you for your fast and welcoming response, I really appreciate it.

Now, I suck at drawing and I'm not an actual engineering student. I'm still in school, so I neither can draw the universally recognized symbols nor can I draw understandable circuits in general, so I'm going to make a (kinda) life sized version using two a4 papers and place the actual equipment on it.


(wheels are sample)

I am using the 9v power supply for stuff that don't truly require the arduino and / or are kinda dangerous long term and can cause damage

I have heard of a multimere and I do plan to get it, but not a DMM. From the fact that I haven't heard of it, I don't think so.

I learned the same guy that I got the code from so I will just do the same thing as you see from the code and we know that right now it isn't working, so what's the point really?

Thank you

Power supply module

here's the full cicuit:

Do the LEDs on the driver flash in sequence?

flashes as C-B-A indivisually

are you powering the 5V stepper motor with the 9V battery?
Try 4 AAs

Should go in sequence A-B-C-D or D-C-B-A

Try removing the motor from the board and try again.

I'm powering it through the bread board power supply module which takes from the 9v battery but gives 5v and 3.3v.
I also don't have AAs rn

Still going C-B-A

Something not right. Check your wiring

it's not just voltage. the 9V battery may not be able to supply sufficient current.

Try this code. It should flash all the LEDs slowly in sequence.
If not, then you have a wiring error or maybe the ULN2003 board is bad.

/* *** DISCONNECT MOTOR *** */

#define STEPPER_PIN_1 9
#define STEPPER_PIN_2 10
#define STEPPER_PIN_3 11
#define STEPPER_PIN_4 12


void setup()
{
  Serial.begin(115200);

  pinMode(STEPPER_PIN_1, OUTPUT);
  pinMode(STEPPER_PIN_2, OUTPUT);
  pinMode(STEPPER_PIN_3, OUTPUT);
  pinMode(STEPPER_PIN_4, OUTPUT);
}

void loop()
{
  digitalWrite(STEPPER_PIN_1, HIGH);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, LOW);
  delay(500);

  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, HIGH);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, LOW);
  delay(500);

  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, HIGH);
  digitalWrite(STEPPER_PIN_4, LOW);
  delay(500);

  digitalWrite(STEPPER_PIN_1, LOW);
  digitalWrite(STEPPER_PIN_2, LOW);
  digitalWrite(STEPPER_PIN_3, LOW);
  digitalWrite(STEPPER_PIN_4, HIGH);
  delay(500);
}

with OneStep(false); as in the code posted, the sequence is D-C-B-A.

Changing to OneStep(true); gives the sequence A-B-C-D.

Note that the pulse width is determined by the time it takes to go round loop( ).
This varies depending on the time it takes for the HC-SR04 to receive an echo.

Hence the stepper motor will speed up (slightly) as it approaches an obstacle.

I took everything off and then reconnected now it still doesn't work but I got A-B-C-D which is really weird since I've seen the reply by @JohnLincoln indicating that with OneStep(false) like in my code which I didn't change, it should go as D-C-B-A

I don't really understand, but I did try to connect it to the arduino's GND and 5V pins, but it still isn't working. Now what changed is the pattern from C-B-A to A-B-C-D

With my code or your original code?

My code. I just realised that you posted code for me to test. Would it be helpful if I try it now?

No.
OK so now you at least get all four steps like you should.
Now reconnect the motor and see if it moves, it will be very very very slow.

When connecting/disconnection wires make sure the power is disconneted.