 
 MotorShield md;
 
-volatile int direction;
+volatile int direction = 1;
 volatile int delta;
 volatile int rightMCtr, leftMCtr;
-
+volatile long timer;
 
 void setup() {
     pinMode(motor_R, INPUT);

  TCCR1B = 0;     // same for TCCR1B

  // set compare match register to desired timer count:
  OCR1A = 1062;   // scale = 1024, OCR1A = (xxx / 64 / 1024)

  // turn on CTC mode:
  TCCR1B |= (1 << WGM12);

}
void detachTimerInterrupt() {
  cli();
  TIMSK1 &= 0; // disable
  sei();
}
ISR(TIMER1_COMPA_vect) {
    md.setM2Speed((300 - delta*5) * direction);
    ++timer;
}
