 }
 
 
-void SetMotor(int pinSpeed, int pin1, int pin2, int speed)
+void SetMotor(int pin1, int pin2, int speed)
 {
-    analogWrite(pinSpeed, abs(speed));
     if (speed < 0)
     {
         analogWrite(pin1, 0);

    if(spinCompleted && range > 0 && range > rangeLimit)
    {
        // drive
        SetMotor(motorPin1_speed, motorPin1_1, motorPin1_2, 255);
        SetMotor(motorPin2_speed, motorPin2_1, motorPin2_2, 255);
        //SetMotor(motorPin3_speed, motorPin3_1, motorPin3_2, 0);
    }
    else
    {
        spinCompleted = false;

        // rotate
        SetMotor(motorPin1_speed, motorPin1_1, motorPin1_2, 255);
        SetMotor(motorPin2_speed, motorPin2_1, motorPin2_2, 0);
        //SetMotor(motorPin3_speed, motorPin3_1, motorPin3_2, 0);

        if(range > (rangeLimit * 2))
        {

const uint8_t trigPin = 9;
const uint8_t echoPin = 10;

const uint8_t ledPin = 11;

const uint8_t motorPin1_1 = 4;
const uint8_t motorPin1_2 = 5;

const uint8_t motorPin2_1 = 7;
const uint8_t motorPin2_2 = 8;


const uint8_t motorEnablePin = 3;

const uint8_t rangeLimit = 15;

