# Stepper motor occasionally not moving

**URL:** <https://forum.arduino.cc/t/stepper-motor-occasionally-not-moving/1204110>\
**Category:** General Electronics\
**Created:** [December 27, 2023, 4:12am UTC](https://forum.arduino.cc/t/stepper-motor-occasionally-not-moving/1204110 "2023-12-27T04:12:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jinghaowangutorontogmailcom](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jinghaowangutorontogmailcom](https://forum.arduino.cc/u/jinghaowangutorontogmailcom)\
**Post date:** [December 27, 2023, 4:12am UTC](https://forum.arduino.cc/t/stepper-motor-occasionally-not-moving/1204110/1 "2023-12-27T04:12:53Z")

</div>

Hi, can someone please help me with this issue?

Issues:

- When the motor rate inside setSpeed() is around 5, the motor runs successfully. But as I increased it to 7 or 8, the movement starts to get bumpy and there are intermittent brakes. When the rate is set to 10, the motor stops and only vibrates.
- Another problem is that the motor keeps on going the same direction after completing one full round of revolution (it's coded to go to the opposite direction after 1 revolution).

Setup:

- Arduino UNO r3.
- Stepper motor: 28BYJ-48.
- 9V battery.

Code:

```arduino
#include <Stepper.h>
int stepsPerRevolution=2048;
int motor_rate=5;
//IN1, IN2, IN3, and IN4 are connected to pin 8,9,10, and 11 respectively.
Stepper myStepper(stepsPerRevolution, 8,9,10,11);

void setup() {
  // put your setup code here, to run once:
myStepper.setSpeed(motor_rate);
}

void loop() {
  // put your main code here, to run repeatedly:
myStepper.step(stepsPerRevolution);
delay(500);
myStepper.step(-stepsPerRevolution);
delay(500);
}

```

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [December 27, 2023, 4:26am UTC](https://forum.arduino.cc/t/stepper-motor-occasionally-not-moving/1204110/2 "2023-12-27T04:26:54Z")

</div>

> [@jinghaowangutorontogmailcom](#):
>
> 9V battery.

That is a problem. Use a power supply capable of powering the system. A 5V phone charger works well if applied to the "5V pin".

Do not attempt to power any motor or servo from the Arduino 5V output when it is powered from a computer, or through Vin. In those cases, motors and servos should be powered separately, but the grounds must be connected.

Servo example:

 ![servo_pwr](https://europe1.discourse-cdn.com/arduino/original/4X/2/8/4/284f634578aa3d13aa3f9977801d67e275067e8a.png)

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [December 27, 2023, 4:33am UTC](https://forum.arduino.cc/t/stepper-motor-occasionally-not-moving/1204110/3 "2023-12-27T04:33:08Z")

</div>

> [@jinghaowangutorontogmailcom](#):
>
> Stepper motor: 28BYJ-48

These steppers require about 0.3A

As mentioned, use an appropriate 5V power supply, 1 to 2 amps should be good.

---

<div class="post-metadata">

**Author:** ![jinghaowangutorontogmailcom](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jinghaowangutorontogmailcom](https://forum.arduino.cc/u/jinghaowangutorontogmailcom)\
**Post date:** [December 27, 2023, 7:41am UTC](https://forum.arduino.cc/t/stepper-motor-occasionally-not-moving/1204110/4 "2023-12-27T07:41:56Z")

</div>

Thank you

---

<div class="post-metadata">

**Author:** ![jinghaowangutorontogmailcom](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jinghaowangutorontogmailcom](https://forum.arduino.cc/u/jinghaowangutorontogmailcom)\
**Post date:** [December 27, 2023, 8:13am UTC](https://forum.arduino.cc/t/stepper-motor-occasionally-not-moving/1204110/5 "2023-12-27T08:13:00Z")

</div>

Thank you

---

<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:** [June 24, 2024, 8:13am UTC](https://forum.arduino.cc/t/stepper-motor-occasionally-not-moving/1204110/6 "2024-06-24T08:13:47Z")

</div>

Closed on June 24, 2024, 8:13am UTC

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