basic time for a DC motor

so i am trying to make a timer to turn off a dc motor after a certain amount of time. Here is what i have and it doesnt seem to work. Any help would be great, i dont have much time left to try and get it working, thanks!

int ledPin = 1;
int ledpin2 = 2;
int clock = 998;
int sec = 30;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(ledpin2, OUTPUT);
}

void loop() {
  sec = sec -1;

  if (sec > 0) {
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledpin2, LOW);
  }

  if (sec <= 0) {
    digitalWrite(ledPin, LOW);
    digitalWrite(ledpin2, LOW);
  }
}

Maybe each loop is too quick, try using “millis” or delay:

int ledPin = 1;
int ledpin2 = 2;
int clock = 998;
int sec = 30;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(ledpin2, OUTPUT);
}

void loop() {
  sec = sec -1;

  if (sec > 0) {
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledpin2, LOW);
  }

  if (sec <= 0) {
    digitalWrite(ledPin, LOW);
    digitalWrite(ledpin2, LOW);
  }

  delay(clock);
}

Sweet thanks a lot! it was incredibly easy i just didn't realize that it was doing it that fast.
Thanks Alot!