1

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.

2
  • 1
    In what code are you stuck? You didn't provide any in your question. If you already have a code, then include it in the question. If not: Have you tried the examples with one of the Arduino stepper libraries (like Stepper or Accelstepper)? 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.
    – chrisl
    Dec 13, 2021 at 9:57
  • Yes I tried with a bunch of code this one work the best for my stepper: drive.google.com/file/d/12Esu1wzS0HfXB_lRHbog6yM09OSJ5SSu/view Dec 13, 2021 at 10:50

1 Answer 1

1

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).

3
  • 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); to loop. 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.