Problem with Stepper IR Control Code

I am trying to get my stepper motor to respond to my IR controls. I'm using a mash up of code from different sources. I've tested the Stepper motor with an independent code, and it works. I've tested the IR receiver with an independent code, and it works. I just can't get my code to work. Below is a diagram, the code, as well as the outputs from the IR remote in the COM Monitor, which I utilized in assigning remote button cases.

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

/*----- Variables, Pins -----*/
#define dirPin 2
#define stepPin 3
#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
int val ; // define numeric variables

/*-----( Declare objects )-----*/

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
  Serial.begin(9600);
}

void loop()
{
  if (irrecv.decode(&results)) // have we received an IR signal?

  {
    switch (results.value)

    {

      case 16748655: // UP button pressed
        small_stepper.setSpeed(500); //Max seems to be 700
        Steps2Take  = 2048;  //
        small_stepper.step(Steps2Take);
        delay(10);
        break;

      case 16769055: // DOWN button pressed
        small_stepper.setSpeed(500);
        small_stepper.step(Steps2Take);
        delay(10);
        break;

      case 16712445: // STOP button pressed
        small_stepper.setSpeed(0);
        Steps2Take  = 0; //
        small_stepper.step(Steps2Take);
        delay(10);
        break;

    }

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

COM Monitor IR Remote Results:

The function decode(&results)) is deprecated and may not work as expected! Just use decode() without a parameter and IrReceiver.decodedIRData. .

Code: 16769055


Code: 16712445


Code: 4294967295


Code: 16748655


Code: 4294967295


Your "schematic" shows the stepper driver connected to pins 2 and 3. It is no wonder that your stepper won't work.

You are using code written for the old version of the IRremote library. You can either change your code to work with the new version of the library, following the instructions that gfvalvo pointed out or you can delete the new version of the IRremote library from your sketchbook/libraries folder and install an older version (2.x.x) and keep the code the way that it is. The older versions are available for install from the IDE library manager.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.