Stepper motor help

I am new to using stepper motors. I read up on them and understand how they work but have no idea on how to write a program. Is there a basic program that will drive a stepper motor in one direction and control the speed with a pot? I would like the motor to continually run depending on the position of the pot. I have the orangutan unit to play with. will that do the job or please suggest what I should be using to accomplish my needs.

Thank you



This link helped me learn a bit: … mples.html

You definitively want a background in getting some code setup.

In some ways, however, you can think of the a4988 stepper driver like an LED. you should do the “example LED” project first. But I’m saying the driver is like an LED because first you set up a direction pin, and you put it HIGH or LOW. Then you “blink” the “step” line every time you want to take a step.

You will need a stepper motor driver in addition to the orangutan unit.

So your directions:
Read up on programming in arduino (assuming you start with them. It’s a great learning platform.) Look up “orangutan programming in arduino environment” worksheet. Or consider picking up a arduino Uno before you work with your orangutan. You need a programmer for the orangutan (frankly I think they should preprogram them with the arduino bootloader. Anyone who doesn’t want to use arduino can use their own programmer.).
Read the schmalzhaus tutorial.
Read all the things you can get your hands on.

Good luck! I hope you enjoy this. It might be frustrating at times. Pay attention to details, they will hit you everywhere.

Other than that, you have an insanely broad question in this post :stuck_out_tongue:

Hello, Tom.

First of all, I am not sure how much experience you have programming your Orangutan. Your first step should be to just compile and load some minimal program onto it. The Pololu AVR Programming Quick Start Guide will help you do that. You do not need to use the Arduino IDE.

After that, you could look at the “stepper-motor1” example in the Pololu AVR Library. You should be able to find it under C:\libpololu-avr , and it comes with all the files necessary to build the example and program it on your Orangutan. (You can also see the source code for stepper-motor1 on github.) This program uses the two H bridges on the Orangutan to control the current going through the stepper motor’s coils. Please read the comment at the top of it for more information.

That method of stepper motor control will work, but if you want a better method that uses current sensing, you should check out our A4988 stepper motor driver and the other drivers like it. The code for controlling those drivers is actually much simpler than the code in stepper-motor1; it’s almost as simple as blinking an LED as Tomek says.


David offers some great advice, and I would defer to his. And since Pololu does have those documents that I didn’t realize existed, you should try to use them to control your stepper motor. I was describing the path I took to learn, but it looks like you can try a different path. I reiterate, though, be prepared to take time reading and learning.

Thank you for the info. I will try to look in to teaching myself how to do this. I will be honest I have no clue on programming. I was hoping it was going to be easy as you telling me to buy this controller and this power supply, type this code and it will work as your looking to do. But after reading its all custom stuff to the equipment your working with.

Thanks for the start of things.


To a certain extent, you are correct. Buy this, buy that, you get your motor running.

With steppermotors particularly, you need to understand a little bit how the code is working. Do you have a particular use for the stepper motor? Perhaps your application could be better suited to a DC motor. In which case, it will be slightly easier to explain how to do the code.

Ultimately, you can follow these background tutorials and get very far. But it will require some several hours before you understand what is happening in coding. I think it was slightly easier for me because I had some experience with matlab for linear algebra class (matlab is based on C++ i believe; familiar style of writing), but even then I had to understand what was going on to simply manage to upload the code, let alone modify it to do what I wanted.