Having trouble with an if statement

:cold_sweat: Still not working =(. It has an LED to monitor the incoming signal FROM the arduino so when i power it up it flashes, so the first time it loops it works, though when i rotate it fast or slow, doesnt send data. Im starting to think i should not Serial.write(analogRead(ofthepot)) but something modified. I thought something happened to the hardware so i changed it to the buggy state (only vHigh!=vHighState) and it works, tho the sent data is with values 1 2 1 2 3 2 3 4 3 4 5 6 5 6 5 6.......
And im thinking i should use unsigned int or something for the analogread, because if i rotate it from 127 towards 0 it would give a negative value (pot - pot before)

Here im putting the code with the things you people said.

#include <AnalogMuxDeMux.h>
#define THRESHOLD 2
AnalogMux amux(13, 12, 11, A1);
#define NO_PINS 8
int vHigh = 0;
int vHighState =0;
int HighEQ = 0;
int vMid = 0;
int vMidState =0;
int MidEQ = 0;
int vBass = 0;
int vBassState = -2*THRESHOLD;
int BassEQ = 0;
int vHigh1 = 0;
int vHigh1State= -2*THRESHOLD;
int HighEQ1 = 0;
int vMid1 = 0;
int vMid1State= -2*THRESHOLD;
int MidEQ1=0;
int vBass1 = 0;
int vBass1State= -2*THRESHOLD;
int BassEQ1=0;
int lastbuttonState =0;
int lastbuttonState1 = 0;
byte CC=176;
byte ON=144;
byte OFF=128;
byte switch1=1;
byte switch2=2;
byte pot1=3;
byte pot2=4;
byte pot3=5;
byte pot4=6;
byte pot5=7;
byte pot6=8;
byte on=127;
byte off=0;

void setup() 
{
  pinMode (13, OUTPUT);
  pinMode (12, OUTPUT);
  pinMode (11, OUTPUT);
  pinMode (A1, INPUT);
  Serial.begin(31250);
}

void loop() 
{

  int sw = amux.AnalogRead (0) / 8;
  int sw1 = amux.AnalogRead(1) / 8;
  int vHigh = amux.AnalogRead(2) / 8;
  int vMid = amux.AnalogRead(3) / 8;
  int vBass = amux.AnalogRead(4) / 8;
  int vHigh1 = amux.AnalogRead(5) / 8;
  int vMid1 = amux.AnalogRead(6) / 8;
  int vBass1 = amux.AnalogRead(7) / 8;


  if (sw != lastbuttonState) 
  {
    if (sw == 127)  {
      Serial.write(ON);
      Serial.write(switch1);
      Serial.write(on);
    }
  }

  if (sw == 0 && lastbuttonState == 127)
  {
    Serial.write(OFF);
    Serial.write(switch1);
    Serial.write(off);
  }
  lastbuttonState=sw;

  if (sw1 != lastbuttonState1) 
  {
    if (sw1 == 127)  {
      Serial.write(ON);
      Serial.write(switch2);
      Serial.write(on);
    }
  }
  if (sw1 == 0 && lastbuttonState1 == 127)
  {
    Serial.write(OFF);
    Serial.write(switch2);
    Serial.write(off);
  }
  lastbuttonState1=sw1;

  if (vHigh != vHighState) 
  {
    Serial.write(CC);
    Serial.write(pot1);
    Serial.write(vHigh); 
  }
  vHighState=vHigh;

  MidEQ = vMid - vMidState;
  MidEQ = abs(MidEQ);

  if (MidEQ > 2) 
  {
    Serial.write(CC);
    Serial.write(pot2);
    Serial.write(vMid);   
  }
  vMidState=vMid;

  if (abs(vBass-vBassState) > THRESHOLD) 
  {
    Serial.write(CC);
    Serial.write(pot3);
    Serial.write(vBass);   
  }
  vBassState=vBass;

  if (abs(vHigh1 - vHigh1State) > THRESHOLD) 
  {
    Serial.write(CC);
    Serial.write(pot4);
    Serial.write(vHigh1);    
  }
  vHigh1State=vHigh1;

  if (abs(vMid1 - vMid1State) > THRESHOLD) 
  {
    Serial.write(CC);
    Serial.write(pot5);
    Serial.write(vMid1);  
  }
  vMid1State=vMid1;

  if (abs(vBass1 - vBass1State) > THRESHOLD) 
  {
    Serial.write(CC);
    Serial.write(pot6);
    Serial.write(vBass1);
  }
  vBass1State=vBass1;



}