Arduino Program Button

Hi. Can someone give me some simple language for a program in Arduino (a “sketch”) to have a stepper move X revolutions back and forth, waiting for a button push between each move?

It would do this: after the Arduino is turned on and power provided to the stepper, one button push moves 10 revolutions forward, the next push moves the stepper back -10 revolutions, and so on.

I tried using pinMode(2, INPUT_PULLUP) to activate the Arduino’s pullup resistor to make the button work, and it did work for a while, then stopped.

Thank you so much if anyone can do this!

AT

Hello.

We do not have any example programs that specifically do that, but there are plenty of stepper motor driver and button examples out there that you could probably pull from to make your own program. Presuming you have a stepper motor driver with a STEP/DIR interface, you might look at the Arduino code in this blog post. As for the button, I suggest looking at this Arduino tutorial for guidance about how to implement that.

- Patrick

This is a very common problem and someone who can post a way to solve it would be helping the world big time.

Button controls are really tricky and not taught well.

Thank you for the suggestion; I am not sure what particular problems with buttons you are referring to, but there are a lot of Arduino resources available for handling buttons, including the one I linked to in my previous post. You might consider posting to the Arduino forum if you are looking for more general programming advice like that.

- Patrick

I posted on Arduino and one month later I still had no answers. Help is hard to find.