Stepper Motor on Uno is Inconsistent!

I am using the sample code from the Elegoo Uno R3 board starter kit along with the kit's stepper motor. The idea is to have a remote control trigger the motor to move one direction or the other for a complete rotation. This much works well when the motor speed is set to the default value(500). But I would like the rotation to go more slowly. When I change the default speed to less than 500 (I have tried 200, 300, 400), it rotates once fully as it should on the first round. But when I click the remote again, the next move is never a full rotation. It seems as if something is interrupting and stopping the motor. Further clicks of the remote provide further inconsistent turns...I can't seem to find any pattern in how far it turns with successive clicks, but always less than a full rotation and rarely more than half a rotation. I checked the motor temperature, it's not even warm. Here is the wiring diagram and code:


#include "Stepper.h"
#include "IRremote.h"

/*----- Variables, Pins -----*/
#define STEPS  32   // Number of steps per revolution of Internal shaft
int  Steps2Take;  // 2048 = 1 Revolution
int receiver = 12; // Signal Pin of IR receiver to Arduino Digital Pin 6

/*-----( Declare objects )-----*/
// Setup of proper sequencing for Motor Driver Pins
// In1, In2, In3, In4 in the sequence 1-3-2-4

Stepper small_stepper(STEPS, 8, 10, 9, 11);
IRrecv irrecv(receiver);    // create instance of 'irrecv'
decode_results results;     // create instance of 'decode_results'

void setup()
  irrecv.enableIRIn(); // Start the receiver

void loop()
if (irrecv.decode(&results)) // have we received an IR signal?



      case 0xFFA857: // VOL+ button pressed
                      small_stepper.setSpeed(200); //Max seems to be 500--THIS IS THE VALUE THAT I CHANGE!

                      Steps2Take  =  2048;  // Rotate CW

      case 0xFF629D: // VOL- button pressed
                      Steps2Take  =  -2048;  // Rotate CCW
      irrecv.resume(); // receive the next value
                 digitalWrite(8, LOW);
                 digitalWrite(9, LOW);
                 digitalWrite(10, LOW);
                 digitalWrite(11, LOW);       

}/* --end main loop -- */

The motor is a 28BYJ-48 4-Phase Stepper Motor with the ULN2003 5V Drive Board for Arduino.

Thanks for any help you can provide!

You should split the project into managing steppers alone, remote comm. etc.
Your description looks like You've thrown all of it into a sack, shaking it and then being surpriced when it doesn't work.
Tell what developing steps You've made.

Put your finger on the breadboard voltage regulator, does it get hot ?

1 Like

Check out my tutorial on Multi-tasking in Arduino which has a complete stepper motor example controlled by user input and a sensor.

1 Like

Your frizzy thing is missing power and ground connections and power source information. Post a schematic instead of this frizzy thing and include links to technical information on all the hardware items. Remember the Arduino a power supply it is NOT! Use a seperate power source for the motors.

1 Like

I didn't write ANY of the code, just changed a single value in the example code--that is the 'stepper speed'.

Thank you! The problem was with the obvious--not using a separate power supply for the motor. It seems to work perfectly now.

1 Like

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