I am trying to control a stepper motor Nema 17 using arduino uno and tb6600 motor driver and ir remote controller tsop1838. The problem i am facing is when i m giving signal to via ir rc the siganl is going to the arduino but the stepper motor is not moving . I need to move the stepper motor in angle 45 to -45 degree so that i also a important need for my project
What do You expect helpers to look at, polnt into and correct?
#include <Stepper.h>
#include <IRremote.h>
const int STEPS_PER_REVOLUTION = 2000; // Number of steps per revolution of your stepper motor
const int STEP_PIN = 8; // Step pin connected to TB6600 driver
const int DIR_PIN = 9; // Direction pin connected to TB6600 driver
Stepper myStepper(STEPS_PER_REVOLUTION, STEP_PIN, DIR_PIN);
const int RECEIVER_PIN = 6; // Signal Pin of IR receiver to Arduino Digital Pin 6
IRrecv irrecv(RECEIVER_PIN);
decode_results results;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the IR receiver
results.value =
// Set initial speed and enable motor
myStepper.setSpeed(500); // Set the initial speed (adjust as needed)
// You might need to set an enable pin HIGH if using TB6600 driver enable functionality
}
void loop() {
if (irrecv.decode(&results)) { // Have we received an IR signal?
switch (results.value) {
case 0xFFFFFFFF: // UP button pressed
Serial.println("UP button pressed");
myStepper.setSpeed(500); // Set the speed (adjust as needed)
myStepper.step(2048); // Rotate clockwise, adjust steps per your motor specs
delay(2000); // Delay to wait for movement to complete
break;
case 0xE1C4F4D5: // DOWN button pressed
Serial.println("DOWN button pressed");
myStepper.setSpeed(500); // Set the speed (adjust as needed)
myStepper.step(-2048); // Rotate counter-clockwise, adjust steps per your motor specs
delay(2000); // Delay to wait for movement to complete
break;
// Add more cases for other remote buttons if needed
default:
Serial.print("Unknown IR code: ");
Serial.println(results.value, HEX);
break;
}
irrecv.resume(); // Receive the next value
}
}
this is my arduino code and i am using tb6600 stepper driver , stepper motor nema 17 jk42 and arduino uno and controlling using ir remote controller tsop 1838. the problem i am facing is that the receiver signals are visible on the serial monitor but the stepper seems to not move a inch . My goal is to set a limit to the stepper between 45 degree cw and 45 degree ccw. Can you please go through code and check if there is any problem
Show the signal received by the Arduino.
Show your wiring diagram.
This usually means "repeated press"
May I suggest you to start with library example sketch for IR receiver. When everything works, move to library example for stepper motor. When that works, go forward with your code.
The Stepper library that comes with the IDEwas not written to be used with step/dir type drivers. There are many drivers hat are. I suggest the MobaTools stepper library.
Make sure to set the coil current before usingthe motor.8
I dont exactly have the perfect wiring diagram but yeah this photos represents the connections i am doing to move the stepper motor . I will share the images of the serial monitor tomorrow. In the serial monitor i get a message stating that i m using older version of irremote lib and i need to use the 4x version . however i m not able to actually understand what exactly do they want me to do because when i made the changes as mentioned in a github code....there seems to be an error thrown by the arduino ...I am new to arduino coding so thats why i am not able to understand the error
Make a clearer picture. Looks like AREF is going to PWR/ALARM.
Why are you using the same color wires for GND and VCC? : |
In your IDE, click the LIBRARY button on the left, type irremote and get the newest version by shirrif.
In the "4x" version, the "&results" is not used. You will need to look in the library examples on how to use the 4.x.x correctly. IDE >> FILE >> EXAMPLES >> IRREMOTE >> (examples)
That's why I suggested you to go step by step with library examples. That way you know that your hardware/wiring/other setup are working and then you can work with your actual code.
i will tell you how i performed my tests. first i tried controlling the ir rc independently and print the HEX codes for all the buttons i press. after completion of this i got the hex codes for some of the buttons i wanted to use that is up and down buttton . that hex codes i used in the above code in which i refered to a utube video and chatgpt to make the entire code. but i am failing to moe the motor and talking about wiring i refered that from utube
Why not ask YouTube and ChatGPT why their code is wrong?
It also looks like you did not listen or respond to any advice from the non-robots, and you probably never will.
sorry for that mistake ... please could you guide me because i am new to arduino coding and also to arduino forum so i have no clue about either of them
Use google translate if you do not understand the advice written in the previous posts.
i tried to follow the steps but the thing is i am not that good in coding and relatively new coz of which i am not able to accurately follow the steps you mentioned
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
