Arduino newbie - Trying to run a stepper-motor.

Hi, I have had an arduino and some accesories lying around for a while but never got time to sit down and try to learn how to use it.

But I would like to know how to get this to work.

I have the following:
Arduino Uno
Wantai 42BYGHW609 Stepper-motor.


L298N H-driver

But how should I connect everything to get started?
And how do I make it move?

You would connect the Output A terminals to motor terminals A, C and the Output B terminals to motor terminals B, D.

Follow the instructions for the driver board to connect the rest of the terminals.

In the Arduino, use the Stepper library to send the correct sequence of signals to the motor. You will need to configure the Stepper library with the pin numbers of the I/O pins that you have connected the input and enable pins to. The Stepper library is documented in the Reference section and includes examples showing how to use it.

go to the motors section of the forum where motor stuff is usually posted.
I just posted a simple sketch with notes.

first,connect power from a power supply to the driver board. do NOT try to power from the arduino.
connect ground to both the power supply, driver board and arduino. (OK, all three)
Note that your 4 output pins go to the 4 enable pins.

change the delay1 and delay2 to a set value like 2 or 5 to test.
1 is fast, 100 is really sloooow use a pot to allow changing these values on the fly.

please note : if you do not like to use delay for testing, please post your version of step_without_delay. thanks!

TROUBLESHOOTING:
swap pins en pins 2 and 3 if you motor only jitters.
or swap en1 and en2 or some combination.
the problem of not getting rotation is often just what pins are selected.
this sketch only energizes one coil at a time.

if this works, go to the motors part of the forum and try the half step version that runs the motor much smoother at low speeds.

int step1 = 6;
int step2 = 7;
int step3 = 8;
int step4 = 9;
int delay1 = 2; //change to 10 to run slower
int delay2 = 2;  //seperate line on pause between steps, increase to run slower

void setup() {                
  // initialize the digital pin as an output.
  pinMode(step1, OUTPUT);     
  pinMode(step2, OUTPUT);   
  pinMode(step3, OUTPUT);   
  pinMode(step4, OUTPUT);   
}

void loop() {
  digitalWrite(step1, HIGH);    
  delay(delay1);               
  digitalWrite(step1, LOW);    
   delay(delay2);     
  digitalWrite(step3, HIGH);    
 delay(delay1);             
  digitalWrite(step3, LOW);    
  delay(delay2);    
  digitalWrite(step2, HIGH);    
   delay(delay1);           
  digitalWrite(step2, LOW);    
  delay(delay2);     
  digitalWrite(step4, HIGH);    
   delay(delay1);             
  digitalWrite(step4, LOW);    
  delay(delay2); 
  }

the left wires to output A and the bottom to out B
some remarks , the motor will get too hot, so you will need to use the enable as pwm.
the diagram is made with 24 volts so 7 times the normal voltage. the max is 1.7 amps for short periodes.
your shield must have 12 volts as lower the shield will not start.

Thanks, I heve got it running now and tried connecting it to a potensiometer to control its speed witch worked OK. I still don't quite understand how to get the Steps/revelation correct, reverse rotation, what microstepping are and why the torque seems to differ when I played around with the steps/revelation settings.

Also how hard would it be to utilise some current sensing for a complete beginner?
I would want to try to have the motor to roll up my window-blinds and I guess I need some current sensing for the motor to know when to stop as the blinds are rised to the top.

And is it possible to keep track of how many steps it took to roll up the blinds and then just reverse the motor and use the same steps it took to roll up but in reverse?

think of a stepper motor as a multi position switch with 200 positions in one circle.
micro are all the positions in between two steppositions.
the torque is different as youy can see the same on the switch with the spring in different positions.

a good stepperdriver has currentcontrol.
put a current meter in the Vin curcuit to get a view.

yes the do exsit but hey need some knowledge.

yes that is why steppermotors are used you do not need feedback on the psoiton. if it is running within its limikts, it will be same going up and down.