   PORTD=portd;
   PORTB=portb;
   PORTC=portc;
+  
+  //Keep direction variables in sync with main variables
+  portddirection=portd;
+  portbdirection=portb;
+  portcdirection=portc;
 }
 
 //Resets all the pins

  }
  
  //Reset the outputs to forward
  PORTD=portd=B00000000;
  PORTD=portd=B00000000;
  PORTD=portd=B00000000;
}


//Do the dirty work of actually toggling outputs to move the drive heads
void tick(){
  
  /* 
   * If there is a period set for control pin 2, count the number of
   * ticks that pass, and toggle the pin if the current period is reached.
