     reversePin = pwmPin4;
   }
   
-  if(value < 0) {
+  /* Drive Backwards */
+  if(value < 127) {
+    /* Map the value to 0 - 255 */
+    value = map(value,127,0,0,255);
     analogWrite(forwardPin, 0);
     analogWrite(reversePin, value);
   }
+  /* Drive Forwards */
   else {
+    /* Map the value to 0 - 255 */
+    value = map(value,128,255,0,255);
     analogWrite(reversePin, 0);
     analogWrite(forwardPin, value);
   }

  return dist;
}

/* Handles receiving serial communication */
void recvSerial() {
  
    if (Serial.available() > 0) {       
        incomingByte = Serial.read();
        Serial.print("received: ");
        Serial.println(incomingByte, DEC);
    }
}

/* Function to drive given PWM pin given value */
void setMotor(int motor, int value) {
  
  /* Map the value to 0 - 255 */
  value = map(value,-100,100,0,255);
  
  Serial.println(value);
  
  int forwardPin;
  int reversePin;


void loop() {
    
    /* Check if serial data is available */
    if (Serial.available() > 0) {       
        byte packet_type = Serial.read();
        
        /* Determine the length of the incoming packet */
        byte packet_length = HARDWARE_MAP[packet_type];
   
        /* Create a array to store the incoming message */
        byte packet[packet_length];
        
        /* Receive the rest of the packet */
        for(int i = 0; i < packet_length; i++) {
          packet[i] = Serial.read();
        }
        
        /* Handle the packet appropriately */
        switch(packet_type) {
          /* Left Motor */
          case 1:
            setMotor(1,packet[0]);
            break;
          /* Right Motor */
          case 2:
            setMotor(2,packet[0]);
            break;
          default:
            break;
        } /* End handle packet type */
    } /* End Receive Serial Data */
} /* End while loop */

/* Read IR value of specified pin */
void readIR(int pin) {
  int val = analogRead(pin);
  getDistance(val);
}
