My stepper dont work. help me please!

#include <IRremote.h>
#include <Servo.h>
#include <Stepper.h>
int IRpin = 7; // pin for the IR sensor
IRrecv irrecv(IRpin);
decode_results results;
Servo myservo;
const int step_360 = 200;
#define STEPS 32
Stepper small_stepper(step_360,3,5,4,6);
Stepper small_stepper2(step_360,10,12,11,13);
void setup()
{
Serial.begin(9600);
small_stepper.setSpeed(60);
irrecv.enableIRIn();
myservo.attach(9);
}
void loop()
{
if (irrecv.decode(&results))
{
irrecv.resume();
}
if (results.value == 4294967295)
{
small_stepper.step(step_360);
delay(2000);
myservo.write(180);
}

}

my type of stepper

Welcome to the forum

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

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

First: edit your post and insert code tags!

Why do you think your servo is not working? The posted code is a bad example because it makes the servo dependent on the working of the IR sensor.

You also failed to post a wiring diagram so we must assume that you wired wrongly.

What exactly do you mean when you say that your servo won't work ?

How is it powered and does it work with the Servo Sweep example ?

i know but when i used the IR, the servo work but the stepper dont

I see that you changed the title of the topic

Is it the servo or stepper that does not work ?

Do they work in sketches that just move them ?
How are they powered ?

no my wiring its good, its in the code

its the stepper. its powered by 5v power supply and they dont work wherever they are

Please post a sketch that just tries to move the stepper at a fixed speed. Post a schematic of the circuit that you are using.

Exactly where does the 5V supply come from and what type od stepper is it ? Post a link to it maybe

how can i create a schematic

Pencil and paper. Photograph it and post it here

i did it

Thanks. Next time, do not apply highlighter markers to the lines. It does not help to make it readable, the opposite is true.

Also please do not edit your posts that have been replied to. It makes the replies seem inappropriate.

ok thanks, so whats the problem?

You show TWO steppers. Have you ever been able to get either stepper to work by itself?

I can't speak for everyone here, but for me the diagram is too hard to read for me to use it. So I have to step back and let other people help you identify the stepper issue.

Same thing with the code, you never applied code tags to it as you were asked to both 12, and 13 posts ago.

You may have a timer software collision, two libraries trying to use the same hardware timer. Consult the library documentation to find out which timers they use.

Did you just try to add code tags? It looks "blocky" like you used some different kind of tag, failed. Anyway, I want you to investigate the hardware timer usage first.

I don't do this often but here is your code, properly formatted for the forum:

#include <IRremote.h>
#include <Servo.h>
#include <Stepper.h>
int IRpin = 7; // pin for the IR sensor
IRrecv irrecv(IRpin);
decode_results results;
Servo myservo;
const int step_360 = 200;
#define STEPS 32
Stepper small_stepper(step_360, 3, 5, 4, 6);
Stepper small_stepper2(step_360, 10, 12, 11, 13);
void setup()
{
  Serial.begin(9600);
  small_stepper.setSpeed(60);
  irrecv.enableIRIn();
  myservo.attach(9);
}
void loop()
{
  if (irrecv.decode(&results))
  {
    irrecv.resume();
  }
  if (results.value == 4294967295)
  {
    small_stepper.step(step_360);
    delay(2000);
    myservo.write(180);
  }

}

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