Hello, I am trying to use this tutorial I found to make a stepper motor work:
Using his code:
/* Simple Stepper Motor Control Exaple Code
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*
*/
// defines pins numbers
const int stepPin = 3;
const int dirPin = 4;
void setup() {
// Sets the two pins as Outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
}
void loop() {
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 200; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(1000); // One second delay
digitalWrite(dirPin,LOW); //Changes the rotations direction
// Makes 400 pulses for making two full cycle rotation
for(int x = 0; x < 400; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(1000);
}
This is my first time doing anything Arduino, and I'm not too good with electronics so please bare with me. I did not go into the "current limiting" section of his tutorial. Here is a list of the components I used:
12 v adaptor: https://www.amazon.com/gp/product/B01GD4ZQRS/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1
stepper motor: https://www.amazon.com/gp/product/B00PNEQI7W/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1
driver: https://www.amazon.com/gp/product/B01FFGAKK8/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1
After I upload the code, the stepper motor might do nothing or it might make random whining and beeping noises depending on the position of the little screw on the driver( i think thats a potentiometer?). There is one time when I uploaded the code the motor appeared to be working. It spun 1 full rotation, paused for a second, spun again, and repeat. But it only spun in one direction, while the code makes it spin one way and then back the other. Then after I screwed the little screw on the driver, I couldnt get it to fully rotate again, just a few degrees in one direction. Please help, thank you in advance.
I have it wired up exactly how it is in the scehmatic, except with a jumper wire from sleep to reset. As for the stepper motor wires I have black to 1b, green to 1a, red to 2a, blue to 2b