In my project I have to control a stepper motor using arduino and microstep driver, can I control the motor so that it can move 90 degrees then stop for like a second and then move again and repeat that sequence. Can I do that please help I'm stuck in the code and I couldn't figure it out.
1 Answer
Of course you can! There are some excellent libraries to control steppers, e.g. Stepper or AccelStepper.
What you describe sounds like basic task that is covered in examples of these libraries. For example, this one: https://github.com/arduino-libraries/Stepper/blob/master/examples/stepper_oneRevolution/stepper_oneRevolution.ino. You only need to set correct pins and tweak delays and rotation angles (if your stepper has 200 steps per revolution, then 90 degrees is 50 steps).
-
This code is working well for me what could I change to get the motion needed drive.google.com/file/d/12Esu1wzS0HfXB_lRHbog6yM09OSJ5SSu/view Dec 13, 2021 at 10:56
-
What to do with that particular code is a whole different question to what was initially asked. That said, your code looks fine, it probably does 2 revolutions continuously (depends on motor). To change that to 90 deg with pause, change 400 to 50 and add
delay(1000);
toloop
. Also, as others noted, you need to understand your code to make it work, there is no other way. Dec 13, 2021 at 11:14 -
Thanks I understand it now and It's working. I'm a beginner when it comes to programming, I tried a lot of codes from AccelStepper and other libraries none has worked for me so, I was frustrated and I wrote the question in a hurry. sorry for that and thank you again for the help. Dec 14, 2021 at 17:23
Stepper
orAccelstepper
)? Have you tried to understand how they work? If you have problems understanding them: What exactly gives you problems here? We need more information to provide good answers.