# Help with code for Geared Stepper Motor and 542T Driver

Hey, I am new to Arduinos and stepper motors. This is what I have:

A Planetary Geared Stepper Motor: http://www.omc-stepperonline.com/gear-ratio-471-planetary-gearbox-nema-23-geared-stepper-motor-23hs222804spg47-p-147.html

Arduino Uno

Power Supply

The Driver has Pul+ Pul- Dir+ Dir- Ena+ Ena-

DC- DC+ A+ A- B+ B-

I have connected Pul+ to #13 on the Arduino Dir+ to #12 on the Arduino Dir- connected into Pul- which is then connected to Ground on the Arduino

Ena+ and Ena- are not connected

Then i have the power supply connected to DC+ and DC- And I have the stepper motor connected to A+ A- B+ and B-

Again, I'm new to this so hopefully those connections look right, if not, let me know what to switch. If they are fine, then we can move onto the code.

I need this motor do do something very simple. I need it to turn 180 degrees in about 3 seconds. Wait a few seconds and then turn in reverse 180 degrees back to where it was.

I wasn't sure how many total steps to use. The stepper motor itself has a step angle of 1.8 degrees. So 200 steps in 1 revolution. However because of this attached planetary gearbox, the step angle on the website says .039 degrees. And then there are the micro steps that can be set from the driver, and I didn't know how to factor those into the code.

Any help would be much appreciated.

Pin 13 might be better avoided because it is for the onboard LED and its electronics are a bit different.

I would start with simple code to move the motor a given number of steps. Then you can vary the number to figure out how many are needed for a full revolution of the output shaft.

This Simple Stepper Code should be suitable for testing - just make sure you match the code to the actual pins you are using.

If you figure that you need (say) 9400 steps (200 * 47) for one revolution then if you select half steps you will need 18,800 steps for a revolution.