 #define MOTOR_FORWARD_TURN          33
 #define MOTOR_REVERSE_FULL          44
 #define MOTOR_REVERSE_TURN          55
-#define MOTOR_RAMP_STEP             25
+
+#define MOTOR_RAMP_STEP             5
+#define LOOP_DELAY_MS				50
 #define MOTOR_RAMP_THHRESHOLD       50
 
 #define BUTTON_MASK                 0x10

          motor_drive_present[i] += MOTOR_RAMP_STEP;    
        }
      }
      
      switch(motor_state[i])
      {
        // drive motors: forward: a = high, b = low; reverse: a = low, b = high; off: both low
        case MOTOR_OFF:
          digitalWrite(front_motor_a[i], LOW);
          digitalWrite(front_motor_b[i], LOW);
          digitalWrite(rear_motor_a[i], LOW);
          digitalWrite(rear_motor_b[i], LOW);
          analogWrite(front_motor_en[i], 0);
          analogWrite(rear_motor_en[i], 0);
          motor_drive_present[i] = 0;
        break;

        case MOTOR_FORWARD_FULL:
          digitalWrite(front_motor_a[i], HIGH);
          digitalWrite(front_motor_b[i], LOW);
          digitalWrite(rear_motor_a[i], HIGH);
          digitalWrite(rear_motor_b[i], LOW);
          //analogWrite(front_motor_en[i], FULL_SPEED);
          //analogWrite(rear_motor_en[i], FULL_SPEED);
          analogWrite(front_motor_en[i], motor_drive_present[i]);
          analogWrite(rear_motor_en[i], motor_drive_present[i]);
          motor_drive_target[i] = FULL_SPEED;
        break;

        case MOTOR_FORWARD_TURN:
          digitalWrite(front_motor_a[i], HIGH);
          digitalWrite(front_motor_b[i], LOW);
          digitalWrite(rear_motor_a[i], HIGH);
          digitalWrite(rear_motor_b[i], LOW);
          analogWrite(front_motor_en[i], TURN_SPEED);
          analogWrite(rear_motor_en[i], TURN_SPEED);
          motor_drive_target[i] = TURN_SPEED;
        break;

        case MOTOR_REVERSE_FULL:
          digitalWrite(front_motor_a[i], LOW);
          digitalWrite(front_motor_b[i], HIGH);
          digitalWrite(rear_motor_a[i], LOW);
          digitalWrite(rear_motor_b[i], HIGH);
          //analogWrite(front_motor_en[i], FULL_SPEED);
          //analogWrite(rear_motor_en[i], FULL_SPEED);
          analogWrite(front_motor_en[i], motor_drive_present[i]);
          analogWrite(rear_motor_en[i], motor_drive_present[i]);          
          motor_drive_target[i] = FULL_SPEED;
        break;

        case MOTOR_REVERSE_TURN:
          digitalWrite(front_motor_a[i], LOW);
          digitalWrite(front_motor_b[i], HIGH);
          digitalWrite(rear_motor_a[i], LOW);
          digitalWrite(rear_motor_b[i], HIGH);
          analogWrite(front_motor_en[i], TURN_SPEED);
          analogWrite(rear_motor_en[i], TURN_SPEED);
          motor_drive_target[i] = TURN_SPEED;
        break;

        default:
          digitalWrite(front_motor_a[i], LOW);
          digitalWrite(front_motor_b[i], LOW);
          digitalWrite(rear_motor_a[i], LOW);
          digitalWrite(rear_motor_b[i], LOW);
          analogWrite(front_motor_en[i], 0);
          analogWrite(rear_motor_en[i], 0);
          motor_drive_target[i] = 0;
        break;
      }
    }
}

      digitalWrite(13, LOW);
    }
    
	set_motor_states(xbee_command & JOYSTICK_MASK);
	
    // read motor states and drive motors    
    for(i = 0; i < 2; i++)
    { 
	  motor_drive_target[i] = set_motor_outputs(motor_state[i]);
	  
	  if (abs(motor_drive_present[i] - motor_drive_target[i]) < MOTOR_RAMP_THHRESHOLD)
      {
        // if close to target, set to target, to reduce jitter
        motor_drive_present[i] = motor_drive_target[i];
      }
      else
