Turning a stepper motor

so my background,
just getting back into this stuff. i haven't been the greatest at it understanding it wise; but i am trying and really want to get good.

so i have found go to get my stepper motor to turn on and rotate.

now i'm trying to put a button in play that when it is pressed it starts the rotation of the stepper and the stepper rotate a certain number of times.

is there a code that exist that does this already for one stepper?
if not where is a good place for me to start to look to understand.

is there an Arduino project that i can do to help myself learn what this type of come is saying and how its applied?

thank you in advance for any patience and help.

RKM 3D D&P

i have found go to get my stepper motor to turn on and rotate

Please post your code here as a starting point

These links may help

Stepper Motor Basics
Simple Stepper Code

If you need more assistance please post a link to the datasheet for your stepper motor and tell us what stepper motor driver you are using.

...R

//Simple stepper motor control demo

const int stepPin = 3; //pin to pulse for steps
const int dirPin = 2; //pin to change step direction

void setup(){

//set pins as outputs
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
}



void loop(){

//step forward 100 steps
stepperFWD();
for(int i = 0; i < 100; i++){
motorStep();
delay(1);
}

//step backwards 100 steps
stepperREV();
for(int i = 0; i < 100; i++){
motorStep();
delay(1);
}

}

//change the stepper direction to forward
void stepperFWD(){
digitalWrite(dirPin, HIGH);
}

//change the stepper direction to reverse
void stepperREV(){
digitalWrite(dirPin, LOW);

}

//have the stepper motor take one step
void motorStep(){
digitalWrite(stepPin, HIGH);
delay(1);
digitalWrite(stepPin, LOW);
}

this is just a code that i have that i took from someone else as a starting point. i will be taking reverse out so that isnt an issue. so this is where im at for trying to understand what is being said. oh yeah how do i attach code so it isnt so big on the screen

Robin2:
These links may help

Stepper Motor Basics
Simple Stepper Code

If you need more assistance please post a link to the datasheet for your stepper motor and tell us what stepper motor driver you are using.

...R

i will for sure look at this.
thank you
RKM

how do i attach code so it isnt so big on the screen

Forum guidelines.

groundFungus:
Forum guidelines.

thank you.

Either You go to a toyshop one lucky day and find the entire proj ready, or You create it Yourself.

Something to start with, what about this:

void loop(){

  if( !start_button( start_button_pin){

    //step forward 100 steps
    stepperFWD();
    for(int i = 0; i < 100; i++){
    motorStep();
    delay(1);
  }
}

Define start_button in Setup as INPUT_PULLUP. Connect the button to GND and button input-