time lapse dolly code problems

i have the limit switches wired from the 5v supply to digital pins 2 and 5 and i have 2 10k ohm resistors between pins 2, 5 and ground.

Toss the resistors. Connect one leg of a switch to ground. Connect the other leg to the digital pin. Turn on the internal pullup resistors.

pinMode(2, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);

Then,

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:

changes. Pressed is LOW.

Plus what AWOL said. There is no excuse for delay(), when the motor should just run the device back and forth.