IR Remote Issues

I'm going to ump in here and hope for some help. I am writing a sketch to control a large stepper NMEA 23 with an attached controller. I have no response from the remote other than key pad indications in the serial print out and each of those is different for a given keypad press. Any help would be appreciated.

#include <AccelStepper.h>
#include <IRremote.h>

#define One_button 0xFF30CF // code received from one button
#define Two_button 0x4eb308f7 // code received from two button
#define Four_button 0x4eb3f00f // code received from four button

// Define sensor pin
int RECV_PIN = 11; //output pin of IR receiver to pin 4 of arduino

AccelStepper stepper(1,3,6); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5

IRrecv irrecv(RECV_PIN); //Arduino will take output of IR receiver from pin 4
decode_results output;

void setup()
{
// Serial Monitor @ 9600 baud
Serial.begin(9600);

// Enable the IR Receiver
irrecv.enableIRIn();

}

void loop()
{
{
if (irrecv.decode(&output))
{
unsigned long value = output.value; // **** change to unsigned long
Serial.println(value, HEX);
switch (value)
{
case One_button:
stepper.setMaxSpeed(5000);
stepper.setSpeed(-3000);
stepper.runSpeed();

break;
case Two_button:
stepper.setMaxSpeed(5000);
stepper.setSpeed(3000);
stepper.runSpeed();

break;
case Four_button:
stepper.setMaxSpeed(10000);
stepper.setSpeed(.0073125);
stepper.setMaxSpeed(10000);
stepper.runSpeed();
break;
}

irrecv.resume();
}
}
}

Split from an old topic

Please do not hijack old topics with new questions

Please follow the advice on posting a programming question given in Read this before posting a programming question

In particular note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless

The runSpeed() function does not do the entire move in one go. You need to repeatedly call this function since it only takes one step at a time. Based on your code, I am assuming that once you send an IR command, you want to complete the entire move before receiving another command. If so, use the runToNewPosition() function sine that will do the entire move before returning. Look at the 'Blocking' example in the AccelStepper library.

I am using this to rotate a dome on an observatory. So once issued I want it to run continuously until I issue another command as in key pad 4 which slows the dome to a tracking speed. I am able to run the sketch section individually and they run as I expect but get no response using the remote.

Post a schematic. Post a data sheet for your IR decoder. What remote are you using? Are you sure that the frequencies match?

Have you successfully ran the IRremote library examples (with nothing else connected to the Arduino)?
What are the results of the IRremoteInfo example?

You can go back and edit your original post to include code tags. Make it easier on folks that want to help you.

mtnclmbr:
I am using this to rotate a dome on an observatory. So once issued I want it to run continuously until I issue another command as in key pad 4 which slows the dome to a tracking speed. I am able to run the sketch section individually and they run as I expect but get no response using the remote.

In that case, you do not want to use the runToNewPosition() but continue to use the commands you have. You will have to move them outside the if() statement that only reacts when an IR code is received. You want to react to the stepper every time though loop() and then check if a new code has arrived and react to that.
Note: in the code below, you will have to define what button is the 'Stop' button to stop moving

#include <AccelStepper.h>
#include <IRremote.h>
#define One_button  0xFF30CF // code received from one button
#define Two_button  0x4eb308f7     // code received from two button
#define Four_button  0x4eb3f00f    // code received from four button
#define Stop_button 0xAAAAAAAA    // code to stop movement
// Define sensor pin
const int RECV_PIN = 11;               //output pin of IR receiver to pin 4 of arduino
AccelStepper stepper(1, 3, 6); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
IRrecv irrecv(RECV_PIN);  //Arduino will take output of IR receiver from pin 4
decode_results output;
void setup()
{
  // Serial Monitor @ 9600 baud
  Serial.begin(9600);
  // Enable the IR Receiver
  irrecv.enableIRIn();
}
void loop()
{
  if (irrecv.decode(&output))
  {
    unsigned long value = output.value; // **** change to unsigned long
    Serial.println(value, HEX);
    switch (value)
    {
      case One_button:
        stepper.setMaxSpeed(5000);
        stepper.setSpeed(-3000);
        break;
      case Two_button:
        stepper.setMaxSpeed(5000);
        stepper.setSpeed(3000);
        break;
      case Four_button:
        stepper.setMaxSpeed(10000);
        stepper.setSpeed(.0073125);
        stepper.setMaxSpeed(10000);
        break;
      case Stop_buttuon:
        stepper.setSpeed(0);
        break;
    }
    irrecv.resume();
  }
  stepper.runSpeed();
}

Thank you blh64. Once I get the remote to respond or work I'll implement that, it makes sense.

blh64, I have it all working now. Thank you!

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