Control a Stepper Motor with an Arduino and IR Remote

Got Questions? Click here and post them in the Brainy-Bits Forum to get help!


Here's a fun and easy way to control a Stepper motor at a distance using an IR Remote control.

The stepper we are using comes with its own driver board making it easy to connect to our UNO.

Since we don't want to drive the motor directly from the UNO, we will be using an inexpensive little breadboard power supply that plugs right on our breadboard and power it with a 9V 1Amp power supply.

The IR sensor is connected to the UNO directly since it uses almost no power.


Control Stepper Motor with an Arduino and IR Remote

We are using 4 pins to control the Stepper and 1 pin for the IR sensor.

Pin 8-11 are controlling the Stepper motor and pin 6 in Receiving the IR information.

We connect the 5V and Ground from to UNO to the sensor and as a precaution, use a breadboard power supply to power the Stepper motor since it can use more power and we don't want to damage the power supply of the UNO.



We use 2 Libraries in our Sketch:  "IRremote" and "Stepper".

The "Stepper" library is included by default with the Arduino Software install.

You will need to download the "IRremote" library and extract it to your Library folder.

The code below only recognize 2 values from the IR Remote control: UP and DOWN.

When UP is pressed on the remote the motor will make a full rotation clockwise.

DOWN will make a full rotation counter-clockwise.


As always you can have a look at the tutorial video for more information.

#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 = 6; // 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 0xFF629D: // UP button pressed
                      small_stepper.setSpeed(500); //Max seems to be 700
                      Steps2Take  =  2048;  // Rotate CW

      case 0xFFA857: // DOWN button pressed
                      Steps2Take  =  -2048;  // Rotate CCW
      irrecv.resume(); // receive the next value

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



Copy and paste the above code in the Arduino IDE to program your Arduino.


Used Libraries:

Download the IRremote created by Ken Shirriff here:


Once downloaded, just extract the content of the zip files inside your “arduino/libraries” folder.


Joel Laws - Jan 27, 2017

Is there anyway to run this program without the arduino plugged into the computer?

Owen - Jan 27, 2017

i keep getting this error and i cant fix it

C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: ‘TKD2’ was not declared in this scope

int RECV_PIN = TKD2; // the pin the IR receiver is connected to ^

Multiple libraries were found for “IRremote.h”
Used: C:\Program Files (x86)\Arduino\libraries\RobotIRremote
Not used: C:\Users\car0095\Documents\Arduino\libraries\Arduino-IRremote-master
exit status 1
Error compiling for board Arduino/Genuino Uno.

ardhendu pandit - Jan 27, 2017

your tutorial vary good

Herman's - Jan 27, 2017

I have a project that controlling the stepper with IR Remote, but i want to make it moving only when i press the button, and when i stop pressing the buton stepper will stop rotate, can you help me to know the program that can i use?

~Thank’s and Great Tutorial, it really usefull ;)

Shawn Smythe - Jan 27, 2017

Is there way to run multiple stepper motor on this code. Trying to control two stepper motor simultaneously using an ir remote

Christian - Jan 27, 2017

Thank you for the tutorial, mine is working great! For anyone using a different IR remote be sure to edit the code: “case 0xFF629D” this segment is specified for his controller. Here is tutorial on how to get your remote’s IR identification number:
Simply replace the “0xFF629D” with whatever your desired buttons IR Identification number. For instance, my code changed to “case 16615543”. Hope this helps anyone that’s struggling.

Ryan - Jan 27, 2017

How can i stop stepper motor while it’s running.
Please help me add case stop

les C - Jan 27, 2017

Great Project. have completed the project thus far , is there a way of putting in a break to stop the motor, also how can you stop the motor going on again if you press the forward button twice by accident ., same in reverse,

Got Questions? Click here and post them in the Brainy-Bits Forum to get help!

Leave a comment

Comments have to be approved before showing up