0

I am currently working on a project which involves picking up plastic balls and depositing them in a box. I am trying to use a stepper motor to move an arm which is attached to a square piece of plywood which has Pringles cans on it. This is how I plan to collect the plastic balls.

The stepper motor needs to move the arm back and forth 180 degrees to collect and deposit the plastic balls. But I am unsure as to how to write the code to accomplish this as I am quite new to Arduino coding. Any form of help would be greatly appreciated. Thank you in advance.

  • 2
    you cannot move the arm 180 degrees until you know how to turn a stepper motor .... start with continuously moving the motor in both directions .... then learn how to move only a specific number of steps – jsotola May 20 at 3:33
  • Plenty of examples on the web already. You can find these via a search engine. – MichaelT May 20 at 21:06
1

There is not enough information about your stepper motor, so let's assume some: let's use stepper motor with 1.8 degree per step (very popular step motor), and we will drive without any microsteps.
To accomplish the task you would need:

  • Arduino,
  • stepper motor,
  • stepper motor driver (like EasyDriver or some kind of Pololu drivers)
  • power supply. To avoid interference I would suggest powering up your Arduino with PC (through USB port) and additional, powerful PSU for the motor/motor driver only.

Now, you would need to provide at least two signals from Arduino to stepper driver (what I am saying here is example of EasyDriver). The signals named DIR and STEP. DIR selects the direction of the motor to spin. Depending of the stepper motor to driver PCB connections you may have clockwise spin when signal is in one state and counterclockwise when DIR is in opposite state. STEP accepts pulses to move the step motor. Driver moves the stepper motor when STEP input sees raising edge. One raising edge equals to one step = 1.8 degree (again, this apply when you do not use microstepping). To spin motor 180 degrees you need 100 steps.
To summarise:

  • Use two ports (simplest solution here with EasyDriver): One defined as DIR, other as STEP.
  • DIR low (selecting one of directions)
  • STEP pulse 100 times (step motor rotates 180 degrees)
  • pause (for whatever needs to be done)

  • DIR high (opposite direction to rotate back)

  • STEP pulse 100 times (stepper motor rotates 180 degrees to initial position)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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