Arduino SA
Search…
Controlling Stepper Motor With Remote
In this lesson, you will learn a fun and easy way to control a stepper motor from a distance using an IR remote control.

Overview

In this lesson, you will learn a fun and easy way to control a stepper motor from 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 R3.
The IR sensor is connected to the UNO R3 directly since it uses almost no power.

Component Required

  • 1 x Arduino UNO R3
  • 1 x IR receiver module
  • 1 x IR remote
  • 1 x ULN2003 stepper motor driver module
  • 1 x Stepper motor
  • 7 x F-M wires (Female to Male DuPont wires)
  • 2 x M-M wire (Male to Male jumper wire)

Connection Diagram

Wiring schematic

Physical wiring diagram

Library Files Required

Please include the Stepper.zip and IRremote.zip to your Library. Download the files below
IRremote.zip
33KB
Binary
Stepper.zip
10KB
Binary

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?
{
switch (results.value)
{
case 0xFFE01F: // “—”button pressed
small_stepper.setSpeed(500); //Max seems to be 500
Steps2Take = 2048; // Rotate CW
small_stepper.step(Steps2Take);
delay(2000);
break;
case 0xFFA857: // “+” button pressed
small_stepper.setSpeed(500);
Steps2Take = -2048; // Rotate CCW
small_stepper.step(Steps2Take);
delay(2000);
break;
}
irrecv.resume(); // receive the next value
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}
}/* --end main loop -- */
18_Controlling_Stepper_Motor_With_Remote.ino
1KB
Binary