Control a 28BYJ-48 stepper motor with any IR remote using Arduino Uno and ULN2003: precise 45° moves, absolute angles, speed control, wiring table, tested IRremote code and Hindi explanation.
Need it ready-made? Buy Ready Project

Stepper motors move in precise, repeatable steps, which is why they are used in 3D printers, CNC machines, camera sliders and automatic curtain openers. In this beginner project you will build an IR remote controlled stepper motor with Arduino Uno, a 28BYJ-48 stepper and the ULN2003 driver board. Using an ordinary TV/”Car MP3″ infrared remote you can rotate the shaft by exactly 45°, jump to fixed angles, run it continuously in either direction, change the speed and send it back to the home position.
The 28BYJ-48 + ULN2003 kit costs very little, runs from 5 V and needs no special power supply for light loads, so it is the perfect first stepper project. You will find the components list, a pin-to-pin wiring table, compile-tested code, a full explanation, troubleshooting tips, an FAQ and a simple Hindi explanation below.
How It Works
The 28BYJ-48 is a small unipolar geared stepper motor. Its internal motor makes 32 full steps per revolution and a 1:64 (approximately) gearbox reduces that, so the output shaft needs about 2048 steps for one full turn in full-step mode. That gives roughly 0.18° per step – very fine positioning. The Arduino cannot drive the coils directly (they need more current than a pin can provide), so the ULN2003 Darlington transistor array switches the four coils on and off when the Arduino sets IN1–IN4 HIGH or LOW.
The IR receiver (VS1838B or TSOP1838) receives the 38 kHz light pulses from the remote and outputs a digital signal. The IRremote library decodes the NEC protocol used by most cheap remotes and gives us a one-byte command code for each key. The sketch maps those codes to actions such as “rotate 45° clockwise”.
Components Required
- Arduino Uno R3 (or Nano) – 1
- 28BYJ-48 5 V stepper motor – 1
- ULN2003 stepper driver board – 1 (usually sold together with the motor)
- IR receiver: VS1838B / TSOP1838 or a 3-pin IR receiver module – 1
- IR remote (21-key “Car MP3” NEC remote, or any NEC TV remote) – 1
- Breadboard and jumper wires
- USB cable; optional separate 5 V 1 A supply for the motor
Wiring Table (Pin-to-Pin)
| Module | Module Pin | Arduino Uno Pin | Notes |
|---|---|---|---|
| ULN2003 board | IN1 | D8 | Stepper pins are passed as 8, 10, 9, 11 in code (IN1, IN3, IN2, IN4) |
| ULN2003 board | IN2 | D9 | |
| ULN2003 board | IN3 | D10 | |
| ULN2003 board | IN4 | D11 | |
| ULN2003 board | + (5–12V) | 5V | For a light load; use an external 5 V supply for heavier loads |
| ULN2003 board | – (GND) | GND | Common ground is required if you use an external supply |
| 28BYJ-48 | 5-pin connector | ULN2003 white socket | Keyed plug – only fits one way |
| IR receiver | OUT / S | D2 | IR_RECEIVE_PIN = 2 |
| IR receiver | GND / – | GND | Check pin order printed on your module |
| IR receiver | VCC / + | 5V |
Bare VS1838B receivers have the pin order OUT – GND – VCC when you look at the dome from the front, but 3-pin modules vary, so always follow the labels on your board. Make sure the ULN2003 board’s power jumper is fitted, otherwise the motor gets no power.
Libraries Used (with Licenses)
- IRremote (version 4.x) by Ken Shirriff, Rafi Khan, Armin Joachimsmeyer and contributors – github.com/Arduino-IRremote/Arduino-IRremote – MIT license.
- Stepper (Arduino) – github.com/arduino-libraries/Stepper – LGPL-2.1 license. Usually pre-installed with the Arduino IDE.
- The sketch is original code written for this article and uses the libraries’ public APIs.
Complete Arduino Code
Board used for the compile test: Arduino Uno (arduino:avr core) with IRremote 4.x. It compiled without errors (about 11.6 KB of flash).
// Arduino Uno IR Remote Controlled 28BYJ-48 Stepper Motor (ULN2003 driver)
// Libraries: IRremote (Arduino-IRremote, MIT) 4.x and Stepper (Arduino, LGPL-2.1)
#include <IRremote.hpp>
#include <Stepper.h>
const int IR_RECEIVE_PIN = 2; // VS1838B / TSOP1838 OUT pin
const int STEPS_PER_REV = 2048; // 28BYJ-48 in full-step mode
// ULN2003 IN1=D8, IN2=D9, IN3=D10, IN4=D11 -> pass in order IN1, IN3, IN2, IN4
Stepper motor(STEPS_PER_REV, 8, 10, 9, 11);
// Command codes of the common 21-key "Car MP3" NEC remote.
// Your remote may differ: open Serial Monitor, press a key and copy the code shown.
const uint8_t KEY_PREV = 0x44; // |<< : 45 degrees counter-clockwise
const uint8_t KEY_NEXT = 0x40; // >>| : 45 degrees clockwise
const uint8_t KEY_PLAY = 0x43; // >|| : start / stop continuous rotation
const uint8_t KEY_MINUS = 0x07; // - : slower
const uint8_t KEY_PLUS = 0x15; // + : faster
const uint8_t KEY_EQ = 0x09; // EQ : change continuous direction
const uint8_t KEY_ZERO = 0x16; // 0 : go back to home position
const uint8_t KEY_DIGIT[9] = {0x0C, 0x18, 0x5E, 0x08, 0x1C, 0x5A, 0x42, 0x52, 0x4A}; // 1..9
int rpm = 10; // 28BYJ-48 works well between 5 and 15 RPM
bool continuous = false;
int direction = 1; // 1 = clockwise, -1 = counter-clockwise
long position = 0; // steps from the home position
void releaseCoils() { // switch coils off so the motor and driver stay cool
for (int pin = 8; pin <= 11; pin++) digitalWrite(pin, LOW);
}
void moveSteps(long steps) {
motor.step(steps);
position += steps;
releaseCoils();
}
void setup() {
Serial.begin(9600);
motor.setSpeed(rpm);
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
Serial.println(F("IR Stepper ready. Press a key on the remote."));
}
void loop() {
if (IrReceiver.decode()) {
uint8_t cmd = IrReceiver.decodedIRData.command;
bool isRepeat = IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT;
IrReceiver.resume();
if (!isRepeat) {
Serial.print(F("Key code: 0x"));
Serial.println(cmd, HEX);
if (cmd == KEY_NEXT) { continuous = false; moveSteps(STEPS_PER_REV / 8); }
else if (cmd == KEY_PREV) { continuous = false; moveSteps(-STEPS_PER_REV / 8); }
else if (cmd == KEY_PLAY) { continuous = !continuous; if (!continuous) releaseCoils(); }
else if (cmd == KEY_EQ) { direction = -direction; }
else if (cmd == KEY_PLUS) { rpm = min(rpm + 2, 15); motor.setSpeed(rpm); }
else if (cmd == KEY_MINUS) { rpm = max(rpm - 2, 3); motor.setSpeed(rpm); }
else if (cmd == KEY_ZERO) { continuous = false; moveSteps(-position); }
else {
for (int i = 0; i < 9; i++) {
if (cmd == KEY_DIGIT[i]) { // digit n -> absolute angle n x 40 degrees
continuous = false;
long target = (long)(i + 1) * STEPS_PER_REV * 40L / 360L;
moveSteps(target - position);
}
}
}
Serial.print(F("RPM: ")); Serial.print(rpm);
Serial.print(F(" Position (deg): ")); Serial.println(position * 360.0 / STEPS_PER_REV, 1);
}
}
if (continuous) {
motor.step(direction * 8); // small chunks keep the remote responsive
position = (position + direction * 8) % STEPS_PER_REV;
}
}Remote Key Map
| Key | Code (hex) | Action |
|---|---|---|
| >>| (Next) | 0x40 | Rotate 45° clockwise |
| |<< (Prev) | 0x44 | Rotate 45° counter-clockwise |
| >|| (Play/Pause) | 0x43 | Start/stop continuous rotation |
| EQ | 0x09 | Reverse the continuous direction |
| + / – | 0x15 / 0x07 | Speed up / slow down (3–15 RPM) |
| 1 – 9 | 0x0C … 0x4A | Go to an absolute angle of 40°, 80° … 360° |
| 0 | 0x16 | Return to the home (start) position |
Code Explanation
- Stepper motor(2048, 8, 10, 9, 11): the 28BYJ-48 needs its coils energised in the order IN1-IN3-IN2-IN4 with the Arduino Stepper library, which is why the middle two pins are swapped. If you pass 8, 9, 10, 11 the motor only vibrates.
- IrReceiver.begin(2, ENABLE_LED_FEEDBACK) starts the decoder; the Uno’s on-board LED (D13) blinks every time an IR signal is received – a quick wiring check.
- decodedIRData.command is the 8-bit key code. Repeat frames (sent when a key is held) are ignored so one press = one action.
- moveSteps() moves the motor, updates the position counter and then calls releaseCoils(), which sets IN1–IN4 LOW so the motor and ULN2003 do not heat up while idle.
- Digit keys calculate an absolute target:
n × 2048 × 40 / 360steps, then move by the difference from the current position. - Continuous mode moves 8 steps per loop so the remote is checked between small moves and the motor reacts immediately when you press Play again.
- Every key press prints its hex code, the speed and the shaft angle to the Serial Monitor at 9600 baud.
Step-by-Step Build Instructions
- Install IRremote by Armin Joachimsmeyer from the Library Manager (version 4.x). The Stepper library is built in.
- Plug the 28BYJ-48 cable into the ULN2003 board.
- Connect IN1–IN4 of the ULN2003 to D8–D11 of the Uno, and its + and – pins to 5V and GND.
- Insert the IR receiver into the breadboard and connect OUT → D2, GND → GND, VCC → 5V.
- Upload the code with board Arduino Uno selected.
- Open the Serial Monitor at 9600 baud and press any key on the remote. You should see “Key code: 0x…”. If your remote shows different codes, copy them into the
KEY_…constants at the top of the sketch and upload again. - Press >>| – the shaft turns 45° clockwise. Press 0 to return home. Try Play for continuous rotation and + / – to change speed.
- Attach a small pointer or a cardboard disc to the shaft to see the angles clearly.
सरल हिंदी में समझें (Simple Hindi Explanation)
इस प्रोजेक्ट में हम एक साधारण IR रिमोट से स्टेपर मोटर को कंट्रोल करते हैं। स्टेपर मोटर छोटे-छोटे कदमों (steps) में घूमती है – 28BYJ-48 मोटर को एक पूरा चक्कर लगाने के लिए लगभग 2048 steps चाहिए। Arduino सीधे मोटर को करंट नहीं दे सकता, इसलिए बीच में ULN2003 ड्राइवर बोर्ड लगाया जाता है।
IR रिसीवर रिमोट के बटन का कोड पढ़कर Arduino को देता है। कोड में हर बटन का काम तय किया गया है – जैसे >>| दबाने पर मोटर 45° घूमती है, Play दबाने पर लगातार घूमती है, + और – से स्पीड बदलती है और 0 दबाने पर मोटर अपनी शुरुआती जगह (home) पर लौट आती है। अगर आपके रिमोट के कोड अलग हैं, तो Serial Monitor में दिख रहे कोड को प्रोग्राम में बदल दें।
Troubleshooting
| Problem | Fix |
|---|---|
| Motor vibrates but does not turn | Pin order is wrong. Use Stepper(2048, 8, 10, 9, 11) exactly, and keep IN1→D8 … IN4→D11. |
| Motor does not move at all, LEDs on ULN2003 dark | Check the power jumper on the ULN2003 board and the 5V/GND wires. |
| Nothing happens when keys are pressed | Check that the D13 LED blinks when you press a key. If not, re-check IR receiver pin order and that OUT is on D2. |
| Wrong key does the wrong thing | Your remote uses different codes. Read them in Serial Monitor and edit the KEY_ constants. |
| Motor skips steps or stalls at high speed | 28BYJ-48 is slow by design. Keep speed at 15 RPM or less and use an external 5 V supply for loads. |
| Arduino resets when the motor starts | USB current is too low. Power the ULN2003 from a separate 5 V supply and connect grounds together. |
Project Ideas
- Remote-controlled curtain or blind opener.
- Rotating display turntable for product photos.
- Pan head for a small camera or phone.
- Automatic fish feeder that turns a disc a fixed angle.
Frequently Asked Questions
Why 2048 steps and not 2038 or 4096?
In full-step mode the output shaft needs about 2048 steps (the exact gear ratio is 63.68:1, so some sources say 2038). In half-step mode, with other libraries such as AccelStepper, it is about 4096.
Can I use any TV remote?
Most remotes using the NEC protocol work directly. Other protocols (Sony, RC5, Samsung) are also decoded by IRremote, but the command codes will be different – read them from the Serial Monitor.
Can I drive a NEMA 17 stepper the same way?
No. NEMA 17 motors are bipolar and need a driver such as the A4988 or DRV8825 with a 12 V supply. The ULN2003 is only for small unipolar motors.
Does the Arduino remember the position after power-off?
No. The position is counted in RAM. For a real application, add a limit switch to find home at start-up.
Why does the motor get warm?
The coils draw current whenever they are energised. The code releases the coils after every move to keep it cool.
Related Projects
- Arduino Ultrasonic Distance Meter with HC-SR04 and LCD
- Arduino Mega Smart Parking System with RFID
- Raspberry Pi Pico Dual-Axis Solar Tracker
- Arduino Clap Switch with KY-038 Sound Sensor
Browse more Robotics on Arduino Project Hub.