Can anyone provide me with code to drive a stepper motor with two limit sw?

Hi all:

Very new to the UNO and coding. I have built a camera slider and mounted a servo motor. I have the code to drive the motor in both direction but want to install limit switches that will reverse the direction.

I got the code and hardware to work with one switch but the second has me stumped!

Does anyone have a sketch they can supply that will achieve my goals?

Thanks in advance!

Frank

Show us your code useing </> tags of course.

maby we can solve the issue on your sketch.

I googled Arduino Stepper motor code with limit switches and got over 84000 hits. I think one of those would help. Google is your friend.

while I agree searching is beneficial...

google doesnt always 'answer back' when you dont understand what you are reading.

however.. without your correct code attempts.. its hard to provide suggestions on what to do.

(please use code tags as mentioned above)

xl97:
while I agree searching is beneficial...

google doesnt always 'answer back' when you dont understand what you are reading.

however.. without your correct code attempts.. its hard to provide suggestions on what to do.

(please use code tags as mentioned above)

I agree, but you should be running code to experiment and learn. Some people come here before doing any searching at all, viewing this as a free consulting site. Providing help to those people is not the mandate of this Forum. I think many of us see this as a "frustration stop" where you come when you've exhausted everything you can think of to solve a problem.

pls clarify:

there is a mismatch between your headline and your text:
do you have a servo motor (what kind) or a stepper motor (what kind) ?

You may find something useful in
Stepper Motor Basics
and in this
Simple Stepper Code

...R