Help about library stepper.h

Hi, when I use the function "nameofthestepper.step(number of steps)" and I introduce a number of steps which is a negative int, it should spin the other way arround, but it doesn't. Why?

What does it do? Move the wrong direction, not move at all or what?

Have you confirmed and tested your wiring and selection of stepper type in you constructor?

Can you find a simple example to test your wiring?

Post your code, use the <\> tool in the message composition window when you do.

a7

It just keeps spinning in the same direction as if the number of steps were positive.

#include <Servo.h>
#include <Stepper.h>
Servo Y;
int steps = 1;
Stepper X(2038,9,10,11,12);
void setup() {
  Serial.begin(9600);
  Y.attach(8);
  X.setSpeed(10);
}

void loop() {
Y.write(map(analogRead(A0),0,1023,90,150));
Serial.println(analogRead(A1));
if(analogRead(A1)>650){
  X.step(steps);
}
if(analogRead(A1)<470){
  X.step(-steps);
}

}

OK.

Make and model of your stepper?

A schematic diagram showing your all connections and power supply would help, probably. Just draw it with a pen or pencil, shoot a picture and post it here.

Sounds like a mismatch between what stepper you have, and what the code thinks you have and/or a wiring error.

a7

Its just a 28BYJ-48 with a controller. It only has a gnd a vcc and 4 pins, which are connected correctly.

2038 steps per revolution. Sure about that?

Also, try removing all the servo stuff or just get a simple example sketch you find somewhere to test your confidence that you have it all hooked right.

a7

Have tried with different numbers there, but 2038 is the one I usually find in youtube tutorials.

Post a link to any source of this disinformation.

So we know where not to go for help, or to whom who should not listen.

a7

I am from Spain, and I have searched for spanish tutorials in youtube and all of them said the number of steps was 2038... I dont remember the name of the channels, sorry.

I always wondered why no one from Spain ever got anywhere with stepper motors.

a7

So what is the problem with my code? And what are the number of steps of the 28BYJ-48?

If you connected it in sequence to the ULN driver ( IN1...IN4 ) you must use

Stepper X(2038,9,11,10,12);

Nominally the stepper 28BYJ-48 has 2048 Steps/Rev. ( 32 steps from the motor itself, and a 1:64 reduction gear ). But there are different versions that may have a slightly different gear ratio. So the Steps/Rev are not always 2048. if you want to know exactly you must test that.

This means there are actually 2038 steps (32*63.68395 steps per revolution = 2037.8864 approximately 2038 steps).

@MicroBahner THX.

@arduyeah please accept my abject apologies. I will slap myself several times with a damp trout, as reqjired by the internet, in an effort to atone for my quick and rudeness.

a7