Add <IRremote> to library

According to Elegoo, Arduino UNO R3 Project #24..

Lesson #24 Controlling Stepper Motor With Remote <IRremote> & <Stepper> need to be added to the library for the project to work.

Errors trying to download the file into the library?

Stepper is already there.

How are you "downloading" the file to "the library" and what errors do you get ?

I don't know about Elegoo lessons, but correct way to add IRRemote library to arduino is via IDE library manager.

  • To install libraries, use "Include Libraries/Manage Libraries" under the "Sketch" tab (IDE 1.8.18).

  • IRremote latest version 4.5

The two libraries are in the "libraries" (if you use English) folder of the downloaded ZIP file.

Thanks UKHeliBob,

I pasted:

#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 12

/*-----( 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'

uint32_t last_decodedRawData = 0;//vairable uses to store the last decodedRawData

void setup()

{

irrecv.enableIRIn(); // Start the receiver

}

void loop()

{

if (irrecv.decode()) // have we received an IR signal?

{

// Check if it is a repeat IR code

if (irrecv.decodedIRData.flags)

{

//set the current decodedRawData to the last decodedRawData

irrecv.decodedIRData.decodedRawData = last_decodedRawData;

}

switch (irrecv.decodedIRData.decodedRawData)

{

case 0xB946FF00: // VOL+ button pressed

small_stepper.setSpeed(500); //Max seems to be 500

Steps2Take = -2048; // Rotate CW

small_stepper.step(Steps2Take);

delay(2000);

break;

case 0xEA15FF00: // VOL- button pressed

small_stepper.setSpeed(500);

Steps2Take = 2048; // Rotate CCW

small_stepper.step(Steps2Take);

delay(2000);

break;

}

//store the last decodedRawData

last_decodedRawData = irrecv.decodedIRData.decodedRawData;

irrecv.resume(); // receive the next value

digitalWrite(8, LOW);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

digitalWrite(11, LOW);

}

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

The immediate error was: C:\Users\ywrf9932\AppData\Local\Temp\arduino_modified_sketch_419028\sketch_jan22a.ino:2:10: fatal error: IRremote.h: No such file or directory

#include "IRremote.h"

      ^~~~~~~~~~~~

compilation terminated.

exit status 1
Error compiling for board Arduino Uno.

BTW.. I was able to get the code uploaded on another computer with the 2 libraries: stepper and IRremote, which did load, but the motor was non responsive upon command using the Vol+/ Vol- buttons??

Please, format and re-post your code in a code block.

How did you install the libraries on the PC where the "IRremote.h: No such file or directory" error occurs ?

Hi @dcerner !

I ported your application to Wokwi (online Arduino Simulator):

See here https://wokwi.com/projects/453955188995745793

It does not receive any IR code and I guess it's related to the newer IRemote version ...

I changed it for V4.5 and added some features:

  • added a state machine to handle the stepper actions
  • replaced delay() by a millis() controlled function
  • added two leds: Green = Reacts onplus/minus commands , Red = Ignores plus/minus commands

See here: https://wokwi.com/projects/453957197937624065

Sketch:

/*
   Forum: https://forum.arduino.cc/t/add-irremote-to-library/1426618/5
   Wokwi: https://wokwi.com/projects/453957197937624065

  Modified for IRemote.hpp V4.5

  ec2021
  2026/01/22


*/


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

enum class CTRL {IDLE, CW, CCW, STOP, WAIT};
CTRL stepperCtrl = CTRL::IDLE;

/*----- Constants Variables, Pins -----*/
constexpr uint8_t leda {7};
constexpr uint8_t ledb {6};

constexpr uint16_t STEPS_PER_REVOLUTION {200};
constexpr uint8_t  IR_RECEIVE_PIN {12}; // Signal Pin of IR receiver to Arduino Digital Pin 12
constexpr unsigned long WAIT_TIME {500};
unsigned long lastStarttime;
int stepsToGo = STEPS_PER_REVOLUTION;

/*-----( 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_PER_REVOLUTION, 8, 10, 9, 11);

void setup()
{
  IrReceiver.begin(IR_RECEIVE_PIN);; // Start the receiver
  small_stepper.setSpeed(200);
  pinMode(leda, OUTPUT);
  pinMode(ledb, OUTPUT);
  green();
}

void loop()
{
  if (IrReceiver.decode()) {
    handleIR();
    IrReceiver.resume();  // Receive the next value
  }
  handleStepper();
}

void handleIR()
{
  switch (IrReceiver.decodedIRData.command) {
    case 2:  // PLUS
      try2changeStepperCtrl(CTRL::CW);
      break;
    case 152: // MINUS
      try2changeStepperCtrl(CTRL::CCW);
      break;
  }
}

void try2changeStepperCtrl(CTRL newCtrl)
{
  if (stepperCtrl != CTRL::WAIT)
  {
    stepperCtrl = newCtrl;
  }
}

void handleStepper()
{
  switch (stepperCtrl)
  {
    case CTRL::WAIT:
      if (millis() - lastStarttime >= WAIT_TIME)
      {
        // In Wokwi the stepper moves one step
        // if we go to CTRL::STOP therefore CTRL:IDLE
        stepperCtrl = CTRL::IDLE;
        green();
      }
      break;
    case CTRL::IDLE:
      // Do nothing
      break;
    case CTRL::CW:
      rotate(-stepsToGo);
      break;
    case CTRL::CCW:
      rotate(stepsToGo);
      break;
    case CTRL::STOP:
      digitalWrite(8, LOW);
      digitalWrite(9, LOW);
      digitalWrite(10, LOW);
      digitalWrite(11, LOW);
      stepperCtrl = CTRL::IDLE;
      break;
  }
}

void rotate(int steps)
{
  red();
  lastStarttime = millis();
  small_stepper.step(steps);
  stepperCtrl = CTRL::WAIT;
}

void green()
{
  digitalWrite(leda, HIGH);
  digitalWrite(ledb, LOW);
}
void red()
{
  digitalWrite(leda, LOW);
  digitalWrite(ledb, HIGH);
}

You don't have to use all the changes. You can just copy the way IRemote is used there. Be aware that the developer of the library recommends to use "#include IRemote.hpp" instead of "#include IRemote.h" for the newer versions:

Converting 2x to 4x version ...

Good luck!
ec2021

Why use hpp instead of ...

Thanks ec2021 Faraday! .. for lending your thoughts here.

I did apply your full rework code from Wokwi. It was cool to see the simulation actually operate on command. However, I’ve yet to see the operation performed from the remote on the physical project.

I’'ll have to try to acquire "#include IRemote.hpp" somehow first. My computer at work doesn’t seem to allow me to get the libraries.

#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 12

/*-----( 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'
uint32_t last_decodedRawData = 0;//vairable uses to store the last decodedRawData

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

void loop()
{
  if (irrecv.decode()) // have we received an IR signal?
  {
    // Check if it is a repeat IR code
    if (irrecv.decodedIRData.flags)
    {
      //set the current decodedRawData to the last decodedRawData
      irrecv.decodedIRData.decodedRawData = last_decodedRawData;
    }
    switch (irrecv.decodedIRData.decodedRawData)
    {

      case 0xB946FF00: // VOL+ button pressed
        small_stepper.setSpeed(500); //Max seems to be 500
        Steps2Take  =  -2048;  // Rotate CW
        small_stepper.step(Steps2Take);
        delay(2000);
        break;

      case 0xEA15FF00: // VOL- button pressed
        small_stepper.setSpeed(500);
        Steps2Take  =  2048;  // Rotate CCW
        small_stepper.step(Steps2Take);
        delay(2000);
        break;

    }
    //store the last decodedRawData
    last_decodedRawData = irrecv.decodedIRData.decodedRawData;
    irrecv.resume(); // receive the next value
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
  }

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


#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 12

/*-----( 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'
uint32_t last_decodedRawData = 0;//vairable uses to store the last decodedRawData

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

void loop()
{
if (irrecv.decode()) // have we received an IR signal?
{
// Check if it is a repeat IR code
if (irrecv.decodedIRData.flags)
{
//set the current decodedRawData to the last decodedRawData
irrecv.decodedIRData.decodedRawData = last_decodedRawData;
}
switch (irrecv.decodedIRData.decodedRawData)
{

  case 0xB946FF00: // VOL+ button pressed
    small_stepper.setSpeed(500); //Max seems to be 500
    Steps2Take  =  -2048;  // Rotate CW
    small_stepper.step(Steps2Take);
    delay(2000);
    break;

  case 0xEA15FF00: // VOL- button pressed
    small_stepper.setSpeed(500);
    Steps2Take  =  2048;  // Rotate CCW
    small_stepper.step(Steps2Take);
    delay(2000);
    break;

}
//store the last decodedRawData
last_decodedRawData = irrecv.decodedIRData.decodedRawData;
irrecv.resume(); // receive the next value
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);

}

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

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

Please post your full sketch, using code tags when you do

Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

I tried to follow the path to get the IRremote.hpp library, but that seems to be my greatest challenge, so far.. or, should I say: how to get that library into the

sketch_feb04a| Arduino 1.8.5 Managed Libraries.

BTW.. I am using an Elegoo UNO R3.

The following ERROR hopefully explains where I am making errors.

Thanks for your patient guidance!



In file included from C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\IRremote.hpp\IRremote.hpp.ino:3:0:

C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\Arduino\libraries\Arduino-IRremote-master\src/IRremote.h:12:2: warning: #warning It seems, that you are using an old version 2.0 code / example. [-Wcpp]

 #warning It seems, that you are using an old version 2.0 code / example.

  ^~~~~~~naged Librarie

C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\Arduino\libraries\Arduino-IRremote-master\src/IRremote.h:13:2: warning: #warning This version is no longer supported! [-Wcpp]

 #warning This version is no longer supported!

  ^~~~~~~

C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\Arduino\libraries\Arduino-IRremote-master\src/IRremote.h:14:2: warning: #warning Upgrade instructions can be found here: "https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#converting-your-2x-program-to-the-4x-version" [-Wcpp]

 #warning Upgrade instructions can be found here: "https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#converting-your-2x-program-to-the-4x-version"

  ^~~~~~~

In file included from C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\IRremote.hpp\IRremote.hpp.ino:3:0:

C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\Arduino\libraries\Arduino-IRremote-master\src/IRremote.h:15:2: warning: #warning Please use one of the new code examples from the library, available at "File > Examples > Examples from Custom Libraries / IRremote". [-Wcpp]

 #warning Please use one of the new code examples from the library, available at "File > Examples > Examples from Custom Libraries / IRremote".

  ^~~~~~~

C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\Arduino\libraries\Arduino-IRremote-master\src/IRremote.h:16:2: warning: #warning Start with the SimpleReceiver or SimpleSender example. [-Wcpp]

 #warning Start with the SimpleReceiver or SimpleSender example.

  ^~~~~~~

C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\Arduino\libraries\Arduino-IRremote-master\src/IRremote.h:17:2: warning: #warning The examples are documented here: "https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#examples-for-this-library" [-Wcpp]

 #warning The examples are documented here: "https://github.com/Arduino-IRremote/Arduino-IRremote?tab=readme-ov-file#examples-for-this-library"

  ^~~~~~~

C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\Arduino\libraries\Arduino-IRremote-master\src/IRremote.h:18:2: warning: #warning Or just downgrade your library to version 2.6.0. [-Wcpp]

 #warning Or just downgrade your library to version 2.6.0.

  ^~~~~~~

C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\IRremote.hpp\IRremote.hpp.ino:15:23: warning: 'IRrecv::IRrecv(uint_fast8_t)' is deprecated: Please use the default IRrecv instance "IrReceiver" and IrReceiver.begin(), and not your own IRrecv instance. [-Wdeprecated-declarations]

 IRrecv irrecv(receiver);    // create instance of 'irrecv'

                       ^

In file included from C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\Arduino\libraries\Arduino-IRremote-master\src/IRremote.hpp:259:0,

                 from C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\Arduino\libraries\Arduino-IRremote-master\src/IRremote.h:10,

                 from C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\IRremote.hpp\IRremote.hpp.ino:3:

C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\Arduino\libraries\Arduino-IRremote-master\src/IRReceive.hpp:79:1: note: declared here

 IRrecv::IRrecv(uint_fast8_t aReceivePin) {

 ^~~~~~

cc1plus.exe: error: C:\Users\ywrf9932\OneDrive - Trinity Health\Documents\arduino-1.8.5\libraries\Stepper\src\Stepper.cpp: Invalid argument

exit status 1
Error compiling for board Arduino Uno.
 Error downloading http://downloads.arduino.cc/libraries/library_index.json
java.lang.RuntimeException: java.lang.Exception: Error downloading http://downloads.arduino.cc/libraries/library_index.json
	at cc.arduino.contributions.libraries.ui.LibraryManagerUI.lambda$onUpdatePressed$0(LibraryManagerUI.java:212)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.Exception: Error downloading http://downloads.arduino.cc/libraries/library_index.json
	at cc.arduino.contributions.DownloadableContributionsDownloader.download(DownloadableContributionsDownloader.java:131)
	at cc.arduino.contributions.JsonDownloader.download(JsonDownloader.java:49)
	at cc.arduino.contributions.GZippedJsonDownloader.download(GZippedJsonDownloader.java:63)
	at cc.arduino.contributions.libraries.LibraryInstaller.updateIndex(LibraryInstaller.java:66)
	at cc.arduino.contributions.libraries.ui.LibraryManagerUI.lambda$onUpdatePressed$0(LibraryManagerUI.java:209)
	... 1 more
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
	at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1959)
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
	at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1514)
	at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
	at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
	at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
	at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
	at cc.arduino.utils.network.FileDownloader.downloadFile(FileDownloader.java:189)
	at cc.arduino.utils.network.FileDownloader.download(FileDownloader.java:128)
	at cc.arduino.contributions.DownloadableContributionsDownloader.download(DownloadableContributionsDownloader.java:129)
	... 5 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:397)
	at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:302)
	at sun.security.validator.Validator.validate(Validator.java:260)
	at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
	at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
	at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
	at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1496)
	... 18 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
	at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
	at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
	at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:392)
	... 24 more

  • Did you install the latest IRremote library ?

  • I took the liberty to change your code as seen below, it works perfectly here.

    • Pin 2 is the IRreceiver pin, Pin 12 is the IR feedback pin, and Pin 13 is used as a heartbeat LED.
#include "Stepper.h"
#include "IRremote.hpp"  // Version 4.4 or newer.

const byte IR_RECEIVE_PIN         = 2;
const byte FEEDBACK_LED_PIN       = 12;  //5v——[220R]——A[LED]K——GND
const byte heartbeatLED           = 13;  //5v——[220R]——A[LED]K——GND
//=====================
// Using a 28BYJ-48 4-Phase Stepper Motor, maximum RPM = 10 to 15.
// 32 motor steps in 360°, * 64(gear ratio) = 32 * 64 = 2048 full steps per revolution (4096 half steps).
// Example: 15rpm = 15rev in 60sec. 15/60 = 1/4 rev per 1 sec; 2048/4 = 512 steps in 1 sec,
// 1/512 = .00195 seconds per step.
// ∴ the maximum stepping motor speed is ~2ms per step
//
int stepsPerRevolution            = 2048;

// Creates an instance of the stepper class.
// Pins entered in sequence:            IN1 IN3 IN2 IN4   = CCW
// For proper step sequence.            IN4 IN2 IN3 IN1   = CW
Stepper small_stepper(stepsPerRevolution, 8, 10,  9, 11);

unsigned long heartbeatTime;


//                                           s e t u p ( )
//================================================^================================================
//
void setup()
{
  Serial.begin(9600);

  pinMode(FEEDBACK_LED_PIN, OUTPUT);
  pinMode(heartbeatLED, OUTPUT);

  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);

  small_stepper.setSpeed(15);

  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK, FEEDBACK_LED_PIN);

}  // END of   setup()


//                                            l o o p ( )
//================================================^================================================
//
void loop()
{
  //========================================================================  T I M E R  heartbeatLED
  //Is it time to toggle the heartbeat LED ?
  if (millis() - heartbeatTime >= 500)
  {
    // Restart this TIMER.
    heartbeatTime = millis();

    // This gives us an indication if our sketch is non-blocking.
    // Toggle the heartbeat LED.
    digitalWrite(heartbeatLED, digitalRead(heartbeatLED) == HIGH ? LOW : HIGH);
  }

  //========================================================================
  // Did we received a new IR command ?
  if (IrReceiver.decode())
  {
    IrReceiver.resume();

    // Get the IR command.
    byte byteRX = IrReceiver.decodedIRData.command;

    // Ignore upcoming "repeat codes".
    IrReceiver.decodedIRData.command = 0;

    // Service this remote button push.
    switch (byteRX)
    {
      //============================== VOL+ button pressed
      case 0x46:
        {
          small_stepper.step(-stepsPerRevolution);
        }
        break;

      //============================== VOL- button pressed
      case 0x15:
        {
          small_stepper.step(stepsPerRevolution);
        }
        break;
    }

    // To save power, turn OFF all coils.
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
  }

} //END of   loop()


//                                              E N D
//================================================^================================================
//

Thank you :eye: Larry D!

Yes, now the IRremote.hpp latest version.. which appears as: (v.4.6) has been uploaded through library.

I don’t know how, but somehow it uploaded I think while I was following the link to GitHub and acquiring the master.zip.

But, I tried clicking through [add file…] under sketch.. so, not exactly sure.. even though I tried previously, and could’t get the library into the manage libraries.

I only know it was there this last time while I was adjusting wires according to your post.

I applied your tweaked code, and moved the 12 pin to 2.. immediately the 4 LEDs on the stepper module ULN2003 came to life, and the heartbeat was there.. low and behold the motor was stepping on command.
I’m just [Curious George].. did you modify independently, or did you use another application?

As mentioned, my biggest hurdle was the library.

But, thank you [as well as others here] for all your support on this one!

@dcerner lets go back to school.

:scream:

  • Run the code from Post #14.
    What happens to the heartbeat LED (Arduino onboard L LED) while the stepper is moving ?

:thinking:




  • Now run the code below.
    What happens to the heartbeat LED (Arduino onboard L LED) while the stepper is moving ?

:roll_eyes:

//================================================^================================================
//                                    IRremote with Stepping Motor
//                                       Non-Blocking Version
//================================================^================================================
//
//  IRremoteStepperStateMachine.ino
//
//  URL
//
//  Author: LarryD
//
//  Version    YY/MM/DD    Comments
//  =======    ========    ========================================================================
//  1.00       26/01/04    Initial code.
//
//
//
//
//  Notes:
//  - Pressing either the UP or Down button makes the stepper move 1 revolution CW or CCW.
//    This is a non-blocking motor movement.
//  - At power up time, if the calibrate switch is pushed, we continue to step the motor
//    until we the switch is released.
//
//


#define DECODE_NEC       // Keep this line before #include "IRremote.hpp".

#include "IRremote.hpp"  // Version 1.4.4.0 or newer.
#include "Stepper.h"


//                                    S T A T E   M A C H I N E
//================================================^================================================
//State Machine
//
enum SystemState
{
  IDLE,
  IR_DETECTION,
  MOVING_STEPPER,
  CALIBRATE_MOTOR
};

SystemState machineState = IDLE;


//                              G P I O s   A n d   V a r i a b l e s
//================================================^================================================
// MACROS.
//
#define PUSHED           LOW
#define RELEASED         HIGH

//=====================
// Stepping Motor.
//
// Using a 28BYJ-48 4-Phase Stepper Motor, maximum RPM = 10 to 15.
// 32 motor steps in 360°, * 64(gear ratio) = 32 * 64 = 2048 full steps per revolution (4096 half steps).
// Many 28BYJ-48 motors are actually closer to a true gear ratio of about 63.683:1 instead of exactly 64:1
// My motor is different, by trial and error, 2058 seems to give the best result.
// Example: 15rpm = 15rev in 60sec. 15/60 = 1/4 rev per 1 sec; 2048/4 = 512 steps in 1 sec,
// 1/512 = .00195 seconds per step.
// ∴ the maximum stepping motor speed is ~2ms per step.
//
//const int stepsPerRevolution     = 2048;
const int stepsPerRevolution      = 2058;      //My stepper works best at 2058

const byte IN1                    = 8;
const byte IN2                    = 9;
const byte IN3                    = 10;
const byte IN4                    = 11;

// Creates an instance of the stepper class.
// Pins entered in sequence:           IN1 IN3 IN2 IN4   = CCW
// For proper step sequence.           IN4 IN2 IN3 IN1   = CW
//
Stepper my_stepper(stepsPerRevolution, IN1, IN3, IN2, IN4);

//=====================
// GPIOs.
//
const byte IR_RECEIVE_PIN         = 2;
const byte calibrateSwitch        = 3;    // [Pin 3]----[Switch]----GND
const byte FEEDBACK_LED_PIN       = 12;
const byte heartbeatLED           = 13;

const int CW                      = -1;
const int CCW                     = 1;
int motorDirection                = CW;

int stepsMoved                    = 0;
int targetSteps                   = 0;
byte byteRX                       = 0;

//=====================
// Timing stuff.
//
unsigned long heartbeatTime;
unsigned long heartbeatInterval   = 500ul;  //500ms

unsigned long servoTime;
unsigned long servoInterval       = 5ul;    //5ms

//=====================
// Miscellaneous.
//
const byte IR_VOL_UP              = 0x46;
const byte IR_VOL_DOWN            = 0x15;

const byte normalSpeed            = 10;   // Note: if we were to use 15, the torque will be less.
const byte slowSpeed              = 5;


//                                           s e t u p ( )
//================================================^================================================
//
void setup()
{
  //Serial.begin(115200);

  pinMode(FEEDBACK_LED_PIN, OUTPUT);
  pinMode(heartbeatLED, OUTPUT);

  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);

  pinMode(calibrateSwitch, INPUT_PULLUP);

  my_stepper.setSpeed(normalSpeed);

  // Are we going into calibration mode ?
  if (digitalRead(calibrateSwitch) == PUSHED)
  {
    // Set motor speed to slow so we can more accurately position the motor.
    my_stepper.setSpeed(slowSpeed);
    motorDirection = CW;

    machineState = CALIBRATE_MOTOR;
  }

  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK, FEEDBACK_LED_PIN);

  // Enable the Callback function. Not used in this example.
  // IrReceiver.registerReceiveCompleteCallback(ReceiveCompleteCallbackHandler);

} // END of   setup()


//                                            l o o p ( )
//================================================^================================================
//
void loop()
{
  //========================================================================
  // Diagnostics:
  // Print the time it takes to return to this same spot.
  // "Comment the next 3 lines when no longer needed."
  //static unsigned long startTime;
  //Serial.println(micros() - startTime);
  //startTime = micros();

  //========================================================================  T I M E R  heartbeatLED
  // Is it time to toggle the heartbeat LED ?
  if (millis() - heartbeatTime >= heartbeatInterval)
  {
    // Restart this TIMER.
    heartbeatTime = millis();

    // This gives us a rough indication if there is blocking code in the sketch.
    // Toggle the heartbeat LED.
    digitalWrite(heartbeatLED, digitalRead(heartbeatLED) == HIGH ? LOW : HIGH);
  }


  //======================================================================== T I M E R  State Machine
  // Is it time to service the State Machine ?
  if (millis() - servoTime >= servoInterval)
  {
    // Restart this TIMER.
    servoTime = millis();

    switch (machineState)
    {
      //========================
      case IDLE:
        {
          idle();
        }
        break;

      //========================
      case IR_DETECTION:
        {
          ir_detection();
        }
        break;

      //========================
      case MOVING_STEPPER:
        {
          moving_stepper();
        }
        break;

      //========================
      case CALIBRATE_MOTOR:
        {
          calibrate_motor();
        }
        break;

    } // END of   switch/case
  }

  //========================================================================


  //================================================
  //       Other non blocking code goes here
  //================================================


} // END of   loop()


//                           S T A T E   M A C H I N E   F U N C T I O N S
//================================================^================================================
//

//========================================================================  idle()
void idle()
{
  // Did we received a new IR command ?
  if (IrReceiver.decode())
  {
    // Get the IR command.
    byteRX = IrReceiver.decodedIRData.command;

    // We will ignore any upcoming "repeat codes" from holding this button.
    IrReceiver.decodedIRData.command = 0;

    IrReceiver.resume();

    machineState = IR_DETECTION;
  }

} // END of   idle()


//========================================================================  ir_detection()
void ir_detection()
{
  // Service this button push.
  switch (byteRX)
  {
    //==============================
    case IR_VOL_UP:
      {
        targetSteps = stepsPerRevolution;
        motorDirection = CW;
        stepsMoved = 0;

        machineState = MOVING_STEPPER;
      }
      break;

    //==============================
    case IR_VOL_DOWN:
      {
        targetSteps = stepsPerRevolution;
        motorDirection = CCW;
        stepsMoved = 0;

        machineState = MOVING_STEPPER;
      }
      break;

    default:
      {
        machineState = IDLE;
      }
      break;

  } // END of   switch/case

  // We are finished with this IR command.
  byteRX = 0;

} // END of   ir_detection()


//========================================================================  moving_stepper()
void moving_stepper()
{
  // Is the motor at its destination ?
  if (stepsMoved < targetSteps)
  {
    stepsMoved++;

    my_stepper.step(motorDirection);

    return;
  }

  // We are finished.
  savePower();

  machineState = IDLE;

} // END of   moving_stepper()


//========================================================================  calibrate_motor()
void calibrate_motor()
{
  // At power up time.
  // Step the motor as long as the switch is pushed.
  if (digitalRead(calibrateSwitch ) == PUSHED)
  {
    my_stepper.step(motorDirection);

    return;
  }

  // Back to normal.
  my_stepper.setSpeed(normalSpeed);
  savePower();

  machineState = IDLE;

} // END of   calibrate_motor()


//                                        F U N C T I O N S
//================================================^================================================
//

//========================================================================  savePower()
void savePower()
{
  // Save power, turn OFF all motor coils.
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);

} // END of   savePower()


//                                              E N D
//================================================^================================================
//

EDIT

Made some minor changes to the sketch here in #16.

Hello again, I fell off the radar for a couple months, and during that time I have checked the circuit from time to time with the intent to eventually get back to trying Larry D's homework assignment [post# 16]. I am finding that the stepper is not working on command. I am not seeing the 4 red LED's on the ULN2003 stepper motor driver module light up either. Battery in remote is good at 3+ Vdc.

Anyone in a similar troubleshoot?

Assuming you are using the sketch from post #16.

  • Show us images of your wiring so we can confirm connections.
  • Is the heartbeat LED flashing ?

Yes. the heartbeat is blinking. The actual IC was getting hot on the polarity divit end.

I ended up replacing the batter anyhow, and now the motor works again.. no heat on the IC

either! Okay, next up.. I will go back to school w/ Larry D.

  • Go back to Post #16 and follow the directions there.

  • It is very difficult for us to see all the wiring connections in your image.

  • Those breadboard power boards are not designed to power motors, what voltage are you feeding it (5v?) , what current can it supply ?