Motor Stepper with micro switch

Hi all..

I have the task of making a tool using stepper motor, LDR sensor, and 2 micro switch ..

The way it works is if the LDR sensor gets the light then the stepper motor to the right, if it is dark then the stepper will go to the left ..

Now the stepper motor code has been successfully moved according to the command from the LDR sensor to the right, how to stop the stepper motor when pressing the micro switch? And re-rotate to the left when it gets dark light, then stop when pressed the micro switch?

Problem only code micro switch ...
Please help
Its code like this:

_1.ino (2.56 KB)

Rather than move 5 steps at a time, just move one step and add code into loop() to check the limit switch. If the switch has been pressed don't do any step.

...R
Stepper Motor Basics
Simple Stepper Code

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile: