   analogWrite(RIGHT_SPEED, abs(rightSpeed));
 }
 
-void handleLeftTick() {
-  if (digitalRead(2) == digitalRead(8)) {
+void leftAChange() {
+  if (digitalRead(M1_A) == digitalRead(M1_B)) {
     ++leftTicks;
   } else {
     --leftTicks;
   }
 }
 
-void handleRightTick() {
-  if (digitalRead(3) != digitalRead(9)) {
+void leftBChange() {
+  if (digitalRead(M1_A) != digitalRead(M1_B)) {
+    ++leftTicks;
+  } else {
+    --leftTicks;
+  }
+}
+
+void rightAChange() {
+  if (digitalRead(M2_A) != digitalRead(M2_B)) {
+    ++rightTicks;
+  } else {
+    --rightTicks;
+  }
+}
+
+void rightBChange() {
+  if (digitalRead(M2_A) == digitalRead(M2_B)) {
     ++rightTicks;
   } else {
     --rightTicks;

  setSpeed(leftMotorCmd, rightMotorCmd);

  if (leftSpeedTarget > 0 || leftSpeed > 0 || rightSpeedTarget > 0 || rightSpeed > 0) {
    Serial.print(loopTime);
    Serial.print("\t");
    Serial.print(leftSpeedTarget);
    Serial.print("\t");

    return 1;
  }
}
