IF statement with boolean

Hello guys

I’ve ran into a bit of trouble, the current code (posted below) checks the temperature and opens/closes a valve depending on the users input temperature (userTemp). Currently I can get the higher/lower if statement to function depending on the value the user wishes, however the first if statement that outputs ‘temperature is good’ always runs too. How can I implement a boolean true/false into this so it is only ran when between the two values?

//Initialisation

//Variables defined
float temp;             // decimal value for read temperature from LM35
int userTemp = 30;          //this will be input to user via bluetooth
int minusBufferTemp;          //float for minus buffer zone
int addBufferTemp;            //float for plus buffer zone
int val = 255;          //speed of the motor between 0 and 255... anything less than 200 does not run.
float bufferVal =  2;





//Pin definitions used
int motorPin1 = 2;      //enable pin for motor in l293 
int motorPin2 = 3;      //enable pin for motor in l293
int enablePin = 9;      // enable pin for l293 
int tempPin = 0;        //Temperature pin for LM35



void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);                // begin serial output
  pinMode(motorPin1, OUTPUT);        // enable motorpin output
  pinMode(motorPin2, OUTPUT);        // enable motorpin output
  pinMode(enablePin, OUTPUT);        // set enable pin as output
  digitalWrite(enablePin, LOW);      //lower enable for l293 pin so motor does not run
}




void loop() {  
  // put your main code here, to run repeatedly

  temp = readtemp();
  Serial.print(temp);
  Serial.print("*C");
  Serial.println();
  Serial.println();
  delay(1000);

  //Calculations for temperature buffer zone.
  float minusBufferTemp = userTemp - bufferVal;
  float addBufferTemp = userTemp + bufferVal;

 int test = (temp > minusBufferTemp && temp < addBufferTemp)



if (test); 
{
  Serial.println("Temperature is good");
  delay(1000);

  //Close Valve
  analogWrite(enablePin, val);
  digitalWrite(motorPin1,LOW);
  digitalWrite(motorPin2, HIGH);

  if(temp < minusBufferTemp)
  {
    Serial.println("Temperature is Lower");
    Serial.println(temp);
    delay(1000);

    //OPEN VALVE 
    analogWrite(enablePin, val);
    digitalWrite(motorPin1,HIGH);
    digitalWrite(motorPin2, LOW);     
  } 

  else {
    if( temp > addBufferTemp)
    {
      Serial.println("Temperature is higher");
      Serial.println(temp);
      delay(1000); 


      //CLOSE VALVE
      analogWrite(enablePin, val);
      digitalWrite(motorPin1, LOW);
      digitalWrite(motorPin2, HIGH);  

    } 
  }
} 

}

int readtemp()      {  
  temp = analogRead(tempPin);
  return temp = round(temp * 0.48828125);    
}

Thanks in advance.

 int test = (temp > minusBufferTemp && temp < addBufferTemp)

is missing a ;

if (test);

has a useless ;

PaulS:

 int test = (temp > minusBufferTemp && temp < addBufferTemp)

is missing a ;

if (test);

has a useless ;

:o That was easier than expected, thanks very much!

EDIT: To clarify I also removed the second if statement from in between the {} and it worked. Now to try and measure resistance of the motor when the valve is fully open!

int minusBufferTemp;          //float for minus buffer zone
int addBufferTemp;            //float for plus buffer zone

When the useless comments do not match the code, the comments are worse than useless.