Help! |controliing step motor with ir remote

Hey Guys,

I am trying to control the 28BYJ-48 stepper motor on and off using the IR remote control, but although there is no apparent problem with the ULN2003A drivers to which my stepper motor is connected, the A, B, C, D LEDs do not turn on and the stepper motor does not work.

I would be very happy if you can help me.

Here its my Code

#include <IRremote.h>
#include <Stepper.h>

const int RECV_PIN = 7; 
const int stepsPerRevolution = 200; 

Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11); 

IRrecv irrecv(RECV_PIN);
decode_results results;

bool motorRunning = false; 
void setup() {
  irrecv.enableIRIn(); 
  Serial.begin(9600);  
  myStepper.setSpeed(60); 
}

void loop() {
  if (irrecv.decode(&results)) {
    if (results.value == 0xBA45FF00) { 
      if (!motorRunning) {
        startMotor();
        motorRunning = true;
      }
    } 
    else if (results.value == 0xB946FF00) { 
      if (motorRunning) {
        stopMotor();
        motorRunning = false;
      }
    }
    irrecv.resume(); 
  }
}

void startMotor() {
  myStepper.step(stepsPerRevolution); 
}

void stopMotor() {
  
}

And my diagram

Verify your remote control circuit works.

Try this way:

//  https://forum.arduino.cc/t/help-controliing-step-motor-with-ir-remote/1250356
#include <IRremote.h>
#include <Stepper.h>
const int RECV_PIN = 7;
const int stepsPerRevolution = 200;
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
IRrecv irrecv(RECV_PIN);
decode_results results;
bool motorRunning = false;
unsigned long value;
//------------------------------------------------------------------------
void setup() {
  irrecv.enableIRIn();
  Serial.begin(9600);
  myStepper.setSpeed(60);
}
//------------------------------------------------------------------------
void loop() {
  if (irrecv.decode()) {
    value = irrecv.decodedIRData.decodedRawData;
    Serial.println(value, HEX);
    if (value == 0xBA45FF00) {
      Serial.println("running");
      if (!motorRunning) {
        startMotor();
        motorRunning = true;
      }
    }
    else if (value == 0xB946FF00) {
      if (motorRunning) {
        stopMotor();
        motorRunning = false;
      }
    }
    irrecv.resume();
  }
}
//------------------------------------------------------------------------
void startMotor() {
   myStepper.step(stepsPerRevolution);
}
//------------------------------------------------------------------------
void stopMotor() {
}
1 Like

It works! Thank you so much.

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