newb here!! need help planning a project

I am learning the basics while trying to make a bit more complex project, at least for me it is complex.

I want to have a stepper motor controlled by the arduino (that is the easy part). When it hits a limit switch I want it to reverse direction until it hits the limit switch on the other side, and then reverse directions again.

I am thinking a flip flop will do the trick, but don't have a clue how to interface it with the stepper or the ardunio. Or could it be done by simply using two sitches in parallel on one pin, and a variable?

Electronically the motor and the limit switches are two seperate issues. Mechanically you have to have an actuator of some kind in the motor shaft or on whatever it drives to press the switches.

You don't need a FF or any external logic, just run the two switches into IO pins on the Arduino and test them before driving the motor.

Two switches, could be on the same pin. Each time a switch is triggered you change the value of a variable that holds your current direction state.

Should be fairly simple. Remember to debounce the switches.

Two switches, could be on the same pin. Each time a switch is triggered you change the value of a variable that holds your current direction state.

As long as the logic holds up. Like if the microcontroller resets, power failure or some other uplanned event.

Edit: I'm sorry. My logic is flawed. The same problems will be there if you are using two inputs.

thanks for the help :slight_smile: