Control a Stepper Motor with an Arduino and IR Remote

//Control a Stepper Motor with an Arduino and IR Remote

Control a Stepper Motor using an IR Remote and an Arduino


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.


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.

By | 2018-02-23T17:28:27-05:00 January 22nd, 2015|Tutorials|


  1. mirakuru August 27, 2019 at 4:31 am - Reply

    hi! I control step motor with Ir module. but ı have a problem please help
    how stop.
    case 0xFF9867:
    Steps2Take = 256;

    Steps2Take = -256;
    (sorry my english is bad)

  2. Conrad April 22, 2019 at 7:31 am - Reply

    Hi. I want to replace the focuser knop on my telescope with a stepper motor to reduce vibrations while taking photos of the moon, planets etc. How can the sketch be modified to allow the stepper motor to initially turn at a high rpm, then press another button on the remote to slow down the stepper motor as the view through the lens sharpens, followed by pressing another button to fine focus. The above sequence must be able to reverse should the focus move past the sharp view through the telescope lens.

  3. Randy April 18, 2019 at 8:03 pm - Reply

    Hi! Just wondering if it is possible to incorporate the number buttons to make the stepper move to a particular position? For example: I have a model railroad with a turntable that has a main feeder line (Home or starting point) then I have 4 tracks leading away to holding roads and diesel shed. Can the numbers be set to match the roads 1-4 and perhaps even allocate another button to return to Home like in the original No1 tutorial video? I would also like to be able to allocate a button to turn the turntable 180° to reverse the direction the locos run. Can you point me to another website or something? Any help would be greatly appreciated. Thanks

  4. David Mensah June 29, 2018 at 7:21 pm - Reply

    I want a program that can give you a specific direction or steps you want. Example if you press 1 would give you step 1 and 2 step2 and when you press 1 again it will come back to step 1

    • Tim June 11, 2019 at 9:13 pm - Reply

      An easy way to do that would be to decode the other buttons from the remote and just at more options in the code itself

Leave A Comment