 }
 
 void loop() {
+  if (initial != digitalRead(startModule)) {
+    while(1) {}
+  }
   cur = millis();
-  if (digitalRead(hallSensorR), HIGH) {
+  if (digitalRead(R_Hall), HIGH) {
     if (!prevHallR) {
       prevHallR = true;
       speedArrR[arrPosR % 5] = cur;

  if ((cur - prevIR) >= 25) {
      // otherwise, poll all the distance sensors
      prevIR = cur;
      rightDist = sensor.getDist();
      leftDist = sensor2.getDist();
      perRightDist = sideright.getDist();
      perLeftDist = sideleft.getDist();

      //attack code with sensors
      if (expectedVelL > getVelL() + hallTimeThresh || expectedVelR > getVelR() + hallTimeThresh) {


  if ((cur - prevLine) >= 5) {
    prevLine = cur;
    if ((analogRead(BL) < threshold || analogRead(BR) < threshold) && lineFlag != 1) {
      //if line detected by back line sensors and wasn't detected before, go forward
      state = 0;
      lineFlag = 1; // set line flag state
      prevFlag = cur;
      pivotFlag = false;
      pastNear = false;
    } else if (analogRead(FL) < threshold && past == 'l' && lineFlag != 2) {
      // if past left and front left hits line and wasn't hit before, turn back right, spin left
      state = 6;
      lineFlag = 2; // set line flag state
      prevFlag = cur;
      pivotFlag = false;
      pastNear = false;
    } else if (analogRead(FL) < threshold && past == 'r' || analogRead(FL) < threshold && past == 'f' && lineFlag != 3) {
      // if past right or forward and front left hits line and wasn't hit before, turn back right, spin right
      state = 7;
      lineFlag = 3; // set line flag state
      prevFlag = cur;
      pivotFlag = false;
      pastNear = false;
    } else if (analogRead(FR) < threshold && past == 'l' && lineFlag != 4) {
      // if past left and front right hits line and wasn't hit before, turn back left, spin right
      state = 8;
      lineFlag = 4; // set line flag state
      prevFlag = cur;
      pivotFlag = false;
      pastNear = false;
    } else if (analogRead(FR) < threshold && past == 'r' || analogRead(FR) < threshold && past == 'f' && lineFlag != 5) {
      // if past right or forward and front right hits line and wasn't hit before, turn back left, spin left
      state = 9;
      lineFlag = 5; // set line flag state
      prevFlag = cur;
      pivotFlag = false;
      pastNear = false;
    } else if (analogRead(FR) < threshold && analogRead(FL) < threshold && lineFlag != 6) {
      // if both front corners hits line and wasn't hit before, go back and spin 180 degrees
      state = 10;
      lineFlag = 6; // set line flag state
