Stepper motor occasionally not moving

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:

#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);
}

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:

These steppers require about 0.3A

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

2 Likes

Thank you

Thank you

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