How to Rotate a Stepper Motor to Pre-Specified Degree + Delay

Hi peeps,

Im brand new to this, and i have little to no experience in programming so i need as much help as possible. What i need the motor to do is rotate 120 degrees then stop for a certain amount of time ex: 10-15 seconds, then repeat. I have looked up the code but i dont know how to actually write if. If someone could just write me the code for that i would greatly appreciate it XD

Thanks You :slight_smile:

And if someone could server my dinner, that would be great too.

Mind you, there is another section where you can ask for "professional help" - meaning you pay for it.

I have looked up the code

Well, what have you looked up? Show that and which bits do not suit you, then we can give a clue where to start modifying it to become your own code.

SonnyBlack:
Im brand new to this, and i have little to no experience in programming so i need as much help as possible.

Start with the basics.

Have you studied the stepper examples that come with the Arduino IDE?
Did you understand them?
If not ask a question and we will try to explain.

Have you actually got a motor - if so post a link to its datasheet.
If NOT, perhaps a servo would be more suitable for your application? The code for that would be myServo.write(120);

...R

@Msquare
Man there is no reason to bash me like that. i never mentioned doing it for free. All i said was i need someone to write the code for me. If you said you can and would like to get paid for it, i would be more than glad to pay for the service you provide. like i said, i'm new to this stuff i don't know how it works so instead of bashing me just give me advice alone like what u said in the other sentence.

@Robin2
This is what i have found in regards to rotating it to the desired degree. then delay it for 15 seconds, then i would like to add a while() so that it can repeat itself. Now i know i have to add few lines before to state what pins the motor is using.i have never programmed before and i don't know how to do this, but this is what i happened to find. This is prob useless unless i have the parts like you stated, so i might be able to give u more detailed info thursday night when i get the parts.

if (stepper.isDone() && rotate1 == true && rotatedeg == false)
{
stepper.setDirection(CW); //rotate clockwise or if i wanted CCW
stepper.rotateDegrees(120);
rotatedeg = true;
delay(15000ms) //delay for 15 seconds
}

Thank you for your replies

i never mentioned doing it for free.

It was implied. There is a section of the forum for posting in, when you are willing to pay.

Man there is no reason to bash me like that.

Awfully thin-skinned, aren't you?

then i would like to add a while() so that it can repeat itself.

So, what's stopping you?

i have never programmed before

Ah, well, there is that. So, why take on this project?

i might be able to give u more detailed info thursday night when i get the parts.

Don't you even know what kind of parts you are getting? What kind of motor? Stepper? Servo? Plain electric motor?

How are you planning to drive the motor? Not directly from an Arduino pin, regardless of what kind of motor it is, so you need something between the Arduino and the motor. What depends on what kind of motor you will be using.

SonnyBlack:
@Robin2
This is what i have found in regards to rotating it to the desired degree.

You did not respond to my suggestion that a servo might be more appropriate for your project than a stepper motor.

You need to tell us what the project actually is.

It is one thing to make a stepper motor with 200 steps per revolution move through 66 or 67 steps (neither is exactly 120 degrees) but it is another thing entirely to get it to move to a specific position because it has no way of knowing where is starts from.

Servos, on the other hand, are designed to move to specific positions.

...R

The waiting is easy , it depends how you're controlling your motor . Let's say you'd use digitalWrite (I don't think this would be used for driving motors , just an example) . Using digitalWrite(name/pin,HIGH) , you can say if the said pin / name would receive current . Then with the delay code you'd say how long .
Now for delaying , you'd say digitalWrite(pin/name, LOW) it would NOT receive current and then delay is used to say how long .
So basically you'd use a code similar to this to delay (do nothing)

digitalWrite(12,LOW);
delay(15000);
// delay for 15 thousand milli seconds

You actually needn't connect anything to 12 - just tell arduino DONT give current to 12 !
Now this is if you'd want things done one at a time .
If you want something else to be done in the meanwhile , you'll have to use while , which honestly I don't know how to work with it .
Hope it was helpful .

from what i understand, nobody is forced to reply to this question. so if you feel like you are a genious and does not want to help, keep quiet and carry on with you life. there is not need for one to come here and bash out at people. if you want to help, then do it, if not, then ignore the question and other people will do.

Tresmalaika:
from what i understand, nobody is forced to reply to this question. so if you feel like you are a genious and does not want to help, keep quiet and carry on with you life. there is not need for one to come here and bash out at people. if you want to help, then do it, if not, then ignore the question and other people will do.

Agreed . And I , honestly , didn't know about how to program a stepper so I tried to help with the easier part I did know about .
Although a simple step program can be done with editing an example .