Problems to make more steps with a nema 17 button

hello good day, I am a bit new in arduino, I wanted to know if it is possible, with one (1) button, to make several sequences of steps (nema17). for example right, left left, right right, left ... thank you very much for helping me guys ... I'm complicated.

You will need a step motor driver but yes you simply detect the button press and do the sequence you want.

hi Indiana ... if I'm using a shielf and in the one controller. you have some idea of how to do it ... I have this sketch but it does not work for me, it does not let me move to the left 200 steps and to the right 400 steps. something like that.

define DISTANCE 500

int StepCounter = 0; int Stepping = false;

void setup () { pinMode (6, OUTPUT); //dirreccion pinMode (3, OUTPUT); //step digitalWrite (6, LOW); digitalWrite (3, LOW);

pinMode (A7, INPUT); // pin del boton1 pinMode (A8, INPUT); // pin del boton 2 }

void loop () { if (digitalRead (A7) == LOW && Stepping == false) { digitalWrite (6, LOW); Stepping = true; } if (digitalRead (A8) == LOW && Stepping == false) { digitalWrite (6, HIGH); Stepping = true; }

if (Stepping == true) { digitalWrite (3, HIGH); delay (1); digitalWrite (3, LOW); delay (1);

StepCounter = StepCounter + 1;

if (StepCounter == DISTANCE) { StepCounter = 0; Stepping = false; } } }

estoy usando un arduino mega + shielf cnc+ driver A4988. motor paso a paso nema 17.

Depends a lot on the motor driver your using. Also you don't have any debouncing on your switch.

Also comment your code, no idea which pin is what and what the different if clauses mean in your loop.

Debounce is not needed: upon press the sequence starts, but until it's done any subsequent presses on the same button don't do anything.

What is needed is pin labels indeed. No idea what it's doing.

Also details on the driver and motor used. Your code appears to put the stepper through 500 steps (in many steppers that would be 2 1/2 rotation) in 1 second, which may be too fast for the motor, depending on the motor and the load it has to move.

lo que quiero hacer es que con un Boton hacer 5 movimientos. capaz tengo que cambiar el driver por un driver l298n.

if (StepCounter == DISTANCE)

Why would you compare the number of steps taken to a distance? The stepper did not move. The mechanism that the stepper controls might have moved, but the stepper is still attached to it's mounting bracket.

Check this how-to on how using the L298N stepper driver with Arduino:

thanks pauls ...

Indiantux excellent post ... I have everything written down and it seems that the l298 driver is the way ... I have to keep moving forward. thanks for giving me a hand eh a little more step for the project and that's a lot ...