Using push button as trigger to loop once

Hi all,

Is there a way to program arduino to start a stepper motor with a single push a button. I mean, what i need to do is;

Stepper motor is at rest I press the button once and release it Stepper motor makes 8 complete revolutions at 20 rpm Then motor stops and waits until the next signal from the button

Just like DVDRWs

Is that possible?

you can simply use "if else", "digitalRead" on pin connected to push button. also may use loop

How will you know that the motor has made 8 revolutions? By timing it? Or do you have a position sensor on it?

the loop() function should always be looping.

One way to do this is to create a separate function for your stepper. then in loop read the button when the button is pressed call the stepper function.

Am I losing my mind, or did you just go back and add "stepper" to your original post?

Maybe you can have an empty loop, have everything in the setup, and use the reset button.


  while button is not pushed do nothing
  operate stepper cycle

Due to the built in delay, you don't need any button debounce.

By 8 revolutions i meant 1600 steps for 1.8 degree motor. Precise position is not important.

I've tried that solution with writing code in the setup portion and leave loop empty and make movement with reset button. But this way, motor starts when i first power up the arduino. I don't want that. It should always wait for the signal. And i'm not good at writing codes, i'm learning with the examples but i have a long way to go. I hoped that someone could throw me an example of the way to do it.

Nobody knows how? :( It sounds so simple but I just couldn't understand the programming. Please if someone knows how, please help me with this i need it too bad.

Two people gave you two different solutions. Are you just in need of a stepper library? They are available.