How do I get my loop to cycle multiple times?

I have a project where I need to make this little motor spin at a certain speed for a certain number of seconds, and then shut down for 30 minutes, and then do that again. I need it to do that four times. I am trying to use a for loop to do that. My problem is that my program will run once but the motor will not run again after that. currently I have very short delays, only a couple seconds, because once this works I can up the time to 30 minutes.

here is the code:

 int motorPin = 10;
int ledPin = 3;

void setup()

  int ledPin;
  int motorPin;
  pinMode (motorPin, OUTPUT);
 pinMode(ledPin, OUTPUT);

void loop()
 //time could = true because if 

  for(int repetitions = 0; repetitions < 4; repetitions = repetitions++)
    delay (4000);
  while(digitalRead(motorPin) == LOW)
  if(millis () == 4000)
    analogWrite(ledPin, 1000);
    analogWrite(motorPin, 70);
    delay (3000);
    analogWrite(ledPin, 0);
    analogWrite(motorPin, LOW);

What can I do to make that LED come on and that motor run four times in a row with a delay in between them?

Take out the for loop. Lose the calls to delay() Read the blink without delay example Use code tags, not quote tags.

What are quote tags?

I need it to delay a little bit because the motor needs to run for a certain amount of time.

They're the things you used when you should have used code tags. It's all explained in the read me stickie at the top of each section of the forum.

If you Modify your post, you will see [ quote ] & /quote Use code and /code instead

T-57: I need it to delay a little bit because the motor needs to run for a certain amount of time.

That's fine, just learn not to use delay().

Ok, I fixed the quote tags to be code tags.

So how do I avoid using delay? And how do I get this motor to run four times with a time interval between?

Blink without delay uses time monitoring vs delay.
So you note the “time”
startTime = millis( );
and monitor millis( ) until enough time has passed to stop the action.
endTime = startTime + duration;

if (millis( ) >= endTime){
// do next event - stop the motor, restart the motor

Maybe add a counter to keep track of how many times its been started.

Ok, so the code format that I just copied from the example here:

  created 2005
 by David A. Mellis
 modified 8 Feb 2010
 by Paul Stoffregen

 This example code is in the public domain.

// constants won't change. Used here to 
// set pin numbers:
const int ledPin =  13;      // the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 1000;           // interval at which to blink (milliseconds)

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);      

void loop()
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the 
  // difference between the current time and last time you blinked 
  // the LED is bigger than the interval at which you want to 
  // blink the LED.
  unsigned long currentMillis = millis();

  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);

So that will make it run and then repeat with an interval?

What is the code for making a timer?

Try some of the Timer libraries in the playground
for example

I have a project where I need to make this little motor spin at a certain speed for a certain number of seconds

Would that be the motor connected to ledPin? Do you plan to connect an LED to motorPin, too?

I wrote a demo sketch that shows a more extensive use of the Blink Without Delay technique in this Thread. It may help to explain the concept.

In simple terms you decide the duration you want for your activity you record the value of millis() just before you start the activity in every iteration of loop() you check whether the latest value of millis() - the start value exceeds your duration if it does, you stop your activity.