 */
 #define ERROR_OUT_OF_RANGE -1
 
+const int BUCKET_SABERTOOTH_ADDRESS = 1;
+
+
 int DIRECTION_PIN = 8;
 int PULSE_PIN = 9;
 int ENABLE = 10;

  pinMode(PULSE_PIN, OUTPUT);
  pinMode(ENABLE, OUTPUT);
  //  digitalWrite(ENABLE, HIGH); //the motor should not make loud screeching
  Serial.begin(9600);
  Serial.println("Send position to go to (percent):");
  printPosition();

double toPercent(int steps) {
  return steps*100.0/FULL_STEPS;
}

/**
 * Drives a given motor at a given speed in a clockwise direction
 *
 * Paramteters:
 *  motorID - the id of the motor to spin (0-11)
 *  speed - the speed at which to spin the motor.
 */
void driveClockwise(int motorID, int speed, unsigned char command){

  
  // Packet format: Address Byte, Command Byte, Value Byte, Checksum.
  // Build the data packet:
  // Get the address and motor command ID from a predefined array.
  unsigned char address = motorID;
  // If the motor is connected backwards, we need to flip the command from 0/4 to 1/5:

  unsigned char checksum = (address + command + ((char)speed)) & 0b01111111;

  // Write the packet.
  Serial3.write(address);
  Serial3.write(command);
  Serial3.write(((char)speed));
  Serial3.write(checksum);
  //TODO: Move the delay time to a constant
  delayMicroseconds(1000); 
}

/**
 * Drives a given motor at a given speed in a counterclockwise direction
 *
 * Paramteters:
 *  motorID - the id of the motor to spin (0-11)
 *  speed - the speed at which to spin the motor.
 */
void driveCounterclockwise(char motorID, char speed, unsigned char command){ 

  // Packet format: Address Byte, Command Byte, Value Byte, Checksum.
  unsigned char address = motorID;
  // If the motor is connected backwards, we need to flip the command from 1/5 to 0/4:

  unsigned char checksum = (address + command + speed) & 0b01111111;
  Serial3.write(address);
  Serial3.write(command);
  Serial3.write(speed);
  Serial3.write(checksum);
  //TODO: Move the delay time to a constant
  delayMicroseconds(1000);
}


