Analog value - High, low and in between

Hi kucza83,
why don't you work only with the current value and old value, instead of calculating two variables:

  val = analogRead(A2);

  if (val > 850)                  //if the read value is more than 850
  {
    lcd.print("high");
  }

  if (val < 300 )
  {
    lcd.print("low");
  }

  if ((val - oldVal)  > 300)          //if the calulated value falls more than 300
  {
    lcd.print("goes up");
  }
  
  if ( (val - oldVal) < -300)              //if the read value is less than 300
  {
    print("goes down");
  }

  oldVal = val;