Overriding Predefined Values in Special Cases

void setup()
{
      pinMode(2, INPUT);
      pinMode(4, INPUT);
      pinMode(5, INPUT);
      pinMode(6, INPUT);
      pinMode(13, INPUT);
      pinMode(7, INPUT);
      pinMode(8, INPUT);
      pinMode(12, INPUT);
      pinMode(11, INPUT);
      pinMode(9, OUTPUT);
      pinMode(10, OUTPUT);
}

void loop()
{
      int notD2 = LOW;
      int D2 = digitalRead(2);
      int notD4 = LOW;
      int D4 = digitalRead(4);
      int notD5 = LOW;
      int D5 = digitalRead(5);
      int notD6 = LOW;
      int D6 = digitalRead(6);
      int navSensor = LOW;
      int D13 = digitalRead(13);
      int D7 = digitalRead(7);
      int D8 = digitalRead(8);
      int notNavSensor = LOW;
      int colorDetect = LOW;
      int noColor = LOW;
      int stopDetect = LOW;
      int splitDetect = LOW;
      int leftNav = LOW;
      int rightNav = LOW;
      int whiteSplit = LOW;
      int colorAndSplit = LOW;
      int leftMuxOut = LOW;
      int D12 = digitalRead(12);
      int D11 = digitalRead(11);
      int rightMuxOut = LOW;
      int D9 = LOW;
      int D10 = LOW;
      notD2 = !(D2);
      notD4 = !(D4);
      notD5 = !(D5);
      notD6 = !(D6);
      navSensor = (D13 || D7 || D8);
      notNavSensor = !(navSensor);
      colorDetect = is_red(0);
      noColor = !(colorDetect);
      stopDetect = (D2 && D4 && D5 && D6 && D13);
      splitDetect = (notD2 && D4 && D5);
      leftNav = !(notNavSensor);
      rightNav = !(navSensor);
      whiteSplit = (noColor && splitDetect);
      colorAndSplit = (colorDetect && splitDetect);
      if(( colorAndSplit == LOW ) && ( stopDetect == LOW ))
      {
            leftMuxOut = leftNav;
      }
      else if(( colorAndSplit == HIGH ) && ( stopDetect == LOW ))
      {
            leftMuxOut = D12;
      }
      else if(( colorAndSplit == LOW ) && ( stopDetect == HIGH ))
      {
            leftMuxOut = D11;
      }
      else
      {
            leftMuxOut = D11;
      }
      if(( whiteSplit == LOW ) && ( stopDetect == LOW ))
      {
            rightMuxOut = rightNav;
      }
      [glow]else if(( whiteSplit == HIGH ) && ( stopDetect == LOW ))
      {
            rightMuxOut = D12;[/glow]
      }
      else if(( whiteSplit == LOW ) && ( stopDetect == HIGH ))
      {
            rightMuxOut = D11;
      }
      else
      {
            rightMuxOut = D11;
      }
      if( rightMuxOut == HIGH )
      {
            analogWrite(9, 178);
      }
      else
      {
            analogWrite(9, 0 );
      }
      if( leftMuxOut == HIGH )
      {
            analogWrite(10, 255);
      }
      else
      {
            analogWrite(10, 0 );
      }
}

boolean is_red( int a_pin )
{
      int x = analogRead(a_pin);
      int v = (x/1024.0)*5.0;
      if( v > 2.5 && v < 3.3 )
            return true;
      else
            return false;
}

Okay so in my introduction to ECE class we’re building this car that is capable of following a white piece of tape around a table. The problem I’m having is when it detects this white split in the table, I need it to go left but as soon as my sensors detect the split and adjust accordingly (turning the right motor on and the left motor off) the other basic navigation sensors start following the white to the right.

Essentially what I am trying to do is find a way to disable the navigation sensors for, say 1 second after detecting the split. When I try and add delay(1000); to the highlighted part of code, I got a compiler error saying that these values are essentially assigned already. If anyone has an idea for how to overcome this issue I would love to hear your input.

tl;dr - I want to override the pre-assigned values for the other sensors when [whiteSplit] is true either by using a delay or just digitalWrite (x, LOW) for a period of time after seeing the split.

Thanks everyone!

The code you posted compiles now.

When I try and add delay(1000); to the highlighted part of code, I got a compiler error saying that these values are essentially assigned already.

The issue, then, is how/where you are trying to add the delay() statement. You didn't show us that.

Originally I had put it in the middle of the highlighted area right before the rightMuxOut = D12; line but I'm fairly certain now that a delay is not what I want to do, rather I want to just manually set the leftMuxOut to LOW whenever whiteSplit is HIGH and rightMuxOut is HIGH. Could I just add a case like

//D11 = low
//D12 = high
(whiteSplit == HIGH) {
leftMuxOut = D11; 

}

up in the part where leftMuxOut is defined?

Could I just add a case like

You're the one with the robot to test it on. Try it and see.