# Stepper Motor Issue (Buzzing)

**URL:** <https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488>\
**Category:** Motors, Mechanics, Power and CNC\
**Created:** [October 21, 2024, 12:15am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488 "2024-10-21T00:15:25Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![graces101](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/graces101/32/921557_2.png) [@graces101](https://forum.arduino.cc/u/graces101)\
**Post date:** [October 21, 2024, 12:15am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/1 "2024-10-21T00:15:25Z")

</div>

Hello! I am a beginner when it comes to arduino. I'm trying to have two joysticks move two stepper motors (left/right, and up/down). However, When testing it out, the stepper motor just buzzes when it's on.

Here is my frizting photo (I am new, sorry it is sloppy). FYI: for A11, it was suppose to be for VRY, not SW.

 ![Screenshot 2024-10-20 at 8.02.49 PM](https://europe1.discourse-cdn.com/arduino/original/4X/8/3/8/838a8b3c74734be06924ddf3bdcbf7d437668f4f.jpeg)

I'll also post my code:

```arduino
#include <Stepper.h>

const int stepsPerRevolution = 2048; // Number of steps per revolution for your stepper motor
const int rolePerMinute = 15;
const int X_pin = 8; // Analog pin connected to X output
const int Y_pin = 11; // Analog pin connected to Y output

// Declare two separate stepper motor objects
Stepper X_stepper(stepsPerRevolution, 22, 24, 26, 28); // X-axis motor
Stepper Y_stepper(stepsPerRevolution, 31, 33, 35, 37); // Y-axis motor (change pins as needed)

void setup() {
  X_stepper.setSpeed(rolePerMinute); // Set speed for X-axis motor
  Y_stepper.setSpeed(rolePerMinute); // Set speed for Y-axis motor
  Serial.begin(9600);
}

void loop() {
  // X-axis control
  Serial.print("X-axis: ");
  int a = analogRead(X_pin);
  Serial.println(a);
  
  if (a > 400 && a < 520) { // Neutral zone
    // Stop the X motor
    for (int i = 2; i < 6; i++) {
      digitalWrite(i, LOW);
    }
  } else if (a < 400) { // Move backward (left)
    X_stepper.setSpeed(rolePerMinute);
    X_stepper.step(-30);
  } else if (a > 530) { // Move forward (right)
    X_stepper.setSpeed(rolePerMinute);
    X_stepper.step(30);
  }

  // Y-axis control
  Serial.print("Y-axis: ");
  int b = analogRead(Y_pin);
  Serial.println(b);

  if (b > 400 && b < 520) { // Neutral zone
    // Stop the Y motor
    for (int i = 6; i < 10; i++) {
      digitalWrite(i, LOW);
    }
  } else if (b < 400) { // Move down
    Y_stepper.setSpeed(rolePerMinute);
    Y_stepper.step(-30);
  } else if (b > 530) { // Move up
    Y_stepper.setSpeed(rolePerMinute);
    Y_stepper.step(30);
  }
}

```

---

<div class="post-metadata">

**Author:** ![Paul\_KD7HB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_kd7hb/32/1127958_2.png) [@Paul\_KD7HB](https://forum.arduino.cc/u/Paul_KD7HB)\
**Post date:** [October 21, 2024, 12:20am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/2 "2024-10-21T00:20:53Z")

</div>

> [@graces101](#):
>
> However, When testing it out, the stepper motor just buzzes when it's on.

More important to debugging your project, what are the values you are seeing on the serial monitor for your two joysticks? Do they change as you move the joysticks? Do they fit the ranges you have coded in your program?

---

<div class="post-metadata">

**Author:** ![graces101](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/graces101/32/921557_2.png) [@graces101](https://forum.arduino.cc/u/graces101)\
**Post date:** [October 21, 2024, 12:22am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/3 "2024-10-21T00:22:35Z")

</div>

Yes they do! The stepper motor is just not spinning, but the LEDS on the driver is on.

---

<div class="post-metadata">

**Author:** ![Paul\_KD7HB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_kd7hb/32/1127958_2.png) [@Paul\_KD7HB](https://forum.arduino.cc/u/Paul_KD7HB)\
**Post date:** [October 21, 2024, 12:24am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/4 "2024-10-21T00:24:00Z")

</div>

> [@graces101](#):
>
> Yes they do!

Do what? Fit within the ranges you programmed? What are some of the values?

---

<div class="post-metadata">

**Author:** ![graces101](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/graces101/32/921557_2.png) [@graces101](https://forum.arduino.cc/u/graces101)\
**Post date:** [October 21, 2024, 12:28am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/5 "2024-10-21T00:28:31Z")

</div>

Yes they fit into the ranges I programmed with. For example, right now the x joystick is at 504. When I slide it to the left, it decrease and goes down to 0 if I push it all the way. When I push it to the right, the max is 1015.

---

<div class="post-metadata">

**Author:** ![graces101](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/graces101/32/921557_2.png) [@graces101](https://forum.arduino.cc/u/graces101)\
**Post date:** [October 21, 2024, 12:33am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/6 "2024-10-21T00:33:39Z")

</div>

Also the LEDs on the driver keep alternating from A to C and B to D whenever I keep on moving the joystick, which is not suppose to happen.

---

<div class="post-metadata">

**Author:** ![Paul\_KD7HB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_kd7hb/32/1127958_2.png) [@Paul\_KD7HB](https://forum.arduino.cc/u/Paul_KD7HB)\
**Post date:** [October 21, 2024, 12:41am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/7 "2024-10-21T00:41:22Z")

</div>

Ok, now what power supply do you have for the motors and doe each motor have it's own supply?

---

<div class="post-metadata">

**Author:** ![graces101](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/graces101/32/921557_2.png) [@graces101](https://forum.arduino.cc/u/graces101)\
**Post date:** [October 21, 2024, 12:55am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/8 "2024-10-21T00:55:07Z")

</div>

What do you mean? Like 5V?

---

<div class="post-metadata">

**Author:** ![Paul\_KD7HB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_kd7hb/32/1127958_2.png) [@Paul\_KD7HB](https://forum.arduino.cc/u/Paul_KD7HB)\
**Post date:** [October 21, 2024, 2:31am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/9 "2024-10-21T02:31:27Z")

</div>

Well, we don;t know what stepper motors you are using, so how are you powering them? A single tiny stepper could be powered by the 5 volts from an Arduino, but two certainly could not be.

---

<div class="post-metadata">

**Author:** ![graces101](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/graces101/32/921557_2.png) [@graces101](https://forum.arduino.cc/u/graces101)\
**Post date:** [October 21, 2024, 2:48am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/10 "2024-10-21T02:48:06Z")

</div>

Oh, the stepper motors are 28BYJ-48 5VDC, and the drivers are ULN2003AN

---

<div class="post-metadata">

**Author:** ![Paul\_KD7HB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_kd7hb/32/1127958_2.png) [@Paul\_KD7HB](https://forum.arduino.cc/u/Paul_KD7HB)\
**Post date:** [October 21, 2024, 4:48am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/11 "2024-10-21T04:48:00Z")

</div>

And the power supply for the two motors?

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [October 21, 2024, 7:05am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/12 "2024-10-21T07:05:18Z")

</div>

Reduce speed to 10 RPM.  
If that does not help, change this:

```arduino
Stepper X_stepper(stepsPerRevolution, 22, 24, 26, 28);

```

To:

```arduino
Stepper X_stepper(stepsPerRevolution, 22, 26, 24, 28);

```

And this:

```arduino
Stepper Y_stepper(stepsPerRevolution, 31, 33, 35, 37);

```

To:

```arduino
Stepper Y_stepper(stepsPerRevolution, 31, 35, 33, 37);

```

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [October 21, 2024, 8:39am UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/13 "2024-10-21T08:39:32Z")

</div>

Hi, @graces101  
Welcome to the forum.

Can I suggest you leave your code for a while and run one of the example codes in the stepper library.  
Just a simple code to make sure your hardware is good.

Can you post some images of your project?  
So we can see your component layout.

What is your 5V supply for the steppers?

Do you have a DMM? (Digital MultiMeter)

Thanks.. Tom... 😃 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![graces101](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/graces101/32/921557_2.png) [@graces101](https://forum.arduino.cc/u/graces101)\
**Post date:** [October 21, 2024, 1:41pm UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/14 "2024-10-21T13:41:46Z")

</div>

Hey, it worked but, it is like stopping and going (I dont know if that makes sense). I did test it with this single code and it worked smoothly. Here is the basic code:

```arduino
#include <Stepper.h>

const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution
const int rolePerMinute = 10;
const int X_pin = 8; // analog pin connected to X output

Stepper myStepper(stepsPerRevolution, 22, 26, 24, 28);
void setup() {
  myStepper.setSpeed(rolePerMinute);
  
  //Serial.begin(9600);

}

void loop() {
// Serial.print("X-axis: ");
// Serial.println(analogRead(X_pin));
  int a = analogRead(X_pin);
  if (a > 400 && a < 520)
  {
    for (int i = 2; i < 6; i++)
    {
      digitalWrite(i, LOW);
    }
  }
  else if (a < 400)
  {
    myStepper.setSpeed(rolePerMinute);
    myStepper.step(-30);
  }
  else if (a > 530)
  {
    myStepper.setSpeed(rolePerMinute);
    myStepper.step(30);
  }

}

```

---

<div class="post-metadata">

**Author:** ![graces101](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/graces101/32/921557_2.png) [@graces101](https://forum.arduino.cc/u/graces101)\
**Post date:** [October 21, 2024, 1:52pm UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/15 "2024-10-21T13:52:15Z")

</div>

Hello! Here is the basic code I ran for 1 stepper motor and it seems to be running smoothy.

However, now that I applied user JCA34F's suggestion to the code I originally had, it moves but it stops and goes. So it's overall slower. Also I will check if I have a DMM.

 ![IMG_4711](https://europe1.discourse-cdn.com/arduino/original/4X/7/2/4/724cff5e3765749fe69b1c56bcee2af21b35a332.jpeg)  
 ![IMG_4712](https://europe1.discourse-cdn.com/arduino/original/4X/c/9/6/c968b84c3a217a6033608a1f169578ffd3252861.jpeg)  
 ![IMG_4713](https://europe1.discourse-cdn.com/arduino/original/4X/1/b/2/1b25315060009aaf3ab4b90ec91f41a8fe588d1d.jpeg)  
 ![IMG_4714](https://europe1.discourse-cdn.com/arduino/original/4X/9/c/9/9c9f71675a18db759ea7739dd12b3e4fef965036.jpeg)

I will admit, I have other things attach to this for a bigger project I'm doing along with the joysticks, but it is attached to the other breadboard (not shown)

```arduino
#include <Stepper.h>

const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution
const int rolePerMinute = 10;
const int X_pin = 8; // analog pin connected to X output

Stepper myStepper(stepsPerRevolution, 22, 26, 24, 28);
void setup() {
  myStepper.setSpeed(rolePerMinute);
  
  //Serial.begin(9600);

}

void loop() {
// Serial.print("X-axis: ");
// Serial.println(analogRead(X_pin));
  int a = analogRead(X_pin);
  if (a > 400 && a < 520)
  {
    for (int i = 2; i < 6; i++)
    {
      digitalWrite(i, LOW);
    }
  }
  else if (a < 400)
  {
    myStepper.setSpeed(rolePerMinute);
    myStepper.step(-30);
  }
  else if (a > 530)
  {
    myStepper.setSpeed(rolePerMinute);
    myStepper.step(30);
  }

}

```

---

<div class="post-metadata">

**Author:** ![graces101](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/graces101/32/921557_2.png) [@graces101](https://forum.arduino.cc/u/graces101)\
**Post date:** [October 21, 2024, 1:53pm UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/16 "2024-10-21T13:53:29Z")

</div>

I am powering them both by 5V from the Arduino Mega

---

<div class="post-metadata">

**Author:** ![Paul\_KD7HB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_kd7hb/32/1127958_2.png) [@Paul\_KD7HB](https://forum.arduino.cc/u/Paul_KD7HB)\
**Post date:** [October 21, 2024, 2:14pm UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/17 "2024-10-21T14:14:38Z")

</div>

Have you measured the 5 volts while powering the steppers? Try a separate 5 volt supply, but connect the - of the supply to the arduino ground.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [April 19, 2025, 2:15pm UTC](https://forum.arduino.cc/t/stepper-motor-issue-buzzing/1313488/18 "2025-04-19T14:15:33Z")

</div>

Closed on April 19, 2025, 2:15pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
