The only problem is that I want to stop the motor once it has rotated the degrees I want, right now as the instruction it is inside the loop it keeps doing the function. I have already set the current of the driver following the equation that appears in the datasheet and the video.īy the way I have found another code that works from the library of arduino. Pin 2 (blue wire) is the step pin and the green wire, pin 3, is the direction pin. I am using an ATX source, black cables connect the grounds of arduino, the driver and the source. I tried your code and still does not work… I attach you a picture of the setup but I guess it is well connected. You should remove the IF / ELSE code block if you do not want your stepper motor to switch direction every 100 steps (or the number of steps the FOR loop will execute). If you look at the comments in the example code carefully, you will see that the IF / ELSE code block “toggle the DIR pin to change direction”, and the FOR loop “trigger the motor to take one step” with each execution. I recommend keeping the minimal connections between your Arduino and stepper motor driver and making some modifications to the code to fix the direction of rotation of your stepper motor. (You can find that information under the “Control inputs” section on any of the A4988 product pages.) Step 1: How to Connect Them We connect the stepper motor to the shield using the following steps: Carefully mount the Arduino Motor Shield on top of the Arduino. However, leaving the DIR pin unconnected means its voltage will be floating, so you should connect it to VCC or GND. Since you do not need to control the direction of your stepper motor’s rotation, you do not need to connect the DIR pin to your Arduino.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |