Usage relay with step motor

Hi,

I planed a project.An object will be taken photo that turn around itself 360 degrees on a rotating step motor.
The step motor rotates 30 degrees and stops and then triggers 2nd pin that takes photo of object. After that
step motor rotates 30 degrees again. I don't know coding well, therefore i only made the motor rotate 30 degrees.
Unfortunantely i didn't make the motor repeat the actions. I wanna the motor rotate and stop and then wait for
3 seconds.At the same time 2nd pin will trigger for 3 seconds and then motor go on rotating again.
Thanks for your help.

#include
CustomStepper stepper(8, 9, 10, 11);
boolean rotatedeg = false;

void setup()
{
stepper.setRPM(12);
stepper.setSPR(4075.7728395);
}

void loop()
{
if (stepper.isDone() && rotatedeg == false)
{
stepper.setDirection(CW);
stepper.rotateDegrees(30);
rotatedeg = true;
}
stepper.run();
}

The step motor rotates 30 degrees and stops and then triggers 2nd pin that takes photo of object. After that
step motor rotates 30 degrees again.

Do some reading up on for loops. They allow you to repeat a series of actions a fixed number of times, so once you know how to move the camera 30 degrees and take a picture you can put that code in a for loop and have it repeat.

For a full rotatation there are 12 lots of 30 degrees, so looping 12 times would be
logical.

If you code up the 30 degree move and triggering the camera and pausing 3 seconds
into a function with a clear name, that will make the code reabable.

void rotate_and_take_photo ()
{
  stepper.setDirection(CW);
  stepper.rotateDegrees(30);
  stepper.runToPosition () ;
  delay (100) ; // wait for motion to fully stop
  trigger_camera() ;
  delay (3000) ;  // allow time for the camera to focus and take picture
}

Now loop() just has to decide when to initiatiate the sequence, which would use
a for-loop to iterate 12 times calling this function.

Disclaimer - its not finished/complete code - you have to do the real work!

To add to what Mark says, you will also need to have something that starts the process of running the for loop and stops it running again until you want it to, otherwise loop() will cause it to run over and over again.

An alternative would be to use the loop() function itself to call the rotate_and_take_photo () function 12 times rather than using a for loop, but you will still need a way of initiating the actions when you need them to occur. Perhaps a push button to start and maybe a second one to abort the actions if necessary.

At some point you will need to stop using the delay() function for timing too.