Variable that changes due to a for loop. Use a particular one in an if statement

you code is not C++ here, missing semi colons and proper call for functions

  int analogValue = readMux(0) //how do I get this inside the if control strucure
   if (analogValue > 500) {
      threshold = true;

      void setLed(int 0, int row, int col, true)

    }//close if
    else { 
      threshold = false;
      void setLed(int 0, int row, int col, false)

    }//close else

if should read

  int analogValue = readMux(0);
  if (analogValue > 500) {
    threshold = true;
    setLed(0,row,col, true);
  }  else {
    threshold = false;
    setLed(0, row, col, false);
  }//close else

then it's fine, you are actually using readMux(0) for the if condition

you could also get rid of analogValue if you don't use it for anything else:

  if (readMux(0) > 500) {
    threshold = true;
    setLed(0,row,col, true);
  }  else {
    threshold = false;
    setLed(0, row, col, false);
  }//close else
1 Like