 
 void loop() {
     
-    setMotor(1, 90);
-    setMotor(2, 90);
-    
-    /*digitalWrite(pwmPin1, LOW);
-    digitalWrite(pwmPin2, HIGH);
-    digitalWrite(pwmPin3, LOW);
-    digitalWrite(pwmPin4, HIGH);*/
-    
-    int stat = digitalRead(statusPin1);
-    Serial.println(stat);
-    
-    stat = digitalRead(statusPin2);
-    Serial.println(stat);
-
-}
+    /* 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);
 }

    reversePin = pwmPin4;
  }
  
  if(value < 0) {
    analogWrite(forwardPin, 0);
    analogWrite(reversePin, value);
  }
  else {
    analogWrite(reversePin, 0);
    analogWrite(forwardPin, value);
  }

  pinMode(pwmPin3, OUTPUT);
  pinMode(pwmPin4, OUTPUT);
  
  /* Configure IR range finders */
  pinMode(irPin, INPUT);

