How to close humidity sensor at specific humidity I am using dht humidity and temperature sensor on arduino and i would like to add relay and buzzer on the system. What I would like to do is to close it via buzzer and on 65% humidity run buzzer. The code i use is:
/* DHT-22 sensor with 12c 16x2 LCD with Arduino uno
   Temperature and humidity sensor displayed in LCD
   based on: http://www.ardumotive.com/how-to-use-dht-22-sensor-en.html and
   https://www.ardumotive.com/i2clcden.html for the i2c LCD library by Michalis Vasilakis
   Recompile by adhitadhitadhit
   Notes: use LCD i2c Library from link above, i'm not sure why but new Liquidcristal library from Francisco Malpartida  isn't working for me
   other thing, check your */

//Libraries
#include &lt;dht.h&gt; // sensor library using lib from https://www.ardumotive.com/how-to-use-dht-22-sensor-en.html
#include &lt;LiquidCrystal_I2C.h&gt; // LCD library using from  https://www.ardumotive.com/i2clcden.html for the i2c LCD library 
#include &lt;Wire.h&gt; 
dht DHT;

//Constants
#define DHT22_PIN 2     // DHT 22  (AM2302) - pin used for DHT22 
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 after finding it from serial monitor (see comment above) for a 16 chars and 2 line display

//Variables
float hum;  //Stores humidity value
float temp; //Stores temperature value

void setup()
{
    Serial.begin(9600);
    lcd.init();                      // initialize the lcd 
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setBacklight(HIGH);
}

void loop()
{
    int chk = DHT.read22(DHT22_PIN);
    //Read data and store it to variables hum and temp
    hum = DHT.humidity;
    temp= DHT.temperature;
    //Print temp and humidity values to LCD
    lcd.setCursor(0,0);
    lcd.print(&quot;Humidity: &quot;);
    lcd.print(hum);
    lcd.print(&quot;%&quot;);
    if (humidity &lt;= 50) 
{ 
   digitalWrite(ledPin, HIGH); 
   digitalWrite(buzzer, HIGH); 

 } 

 else 

 { 

 digitalWrite(ledPin, LOW); digitalWrite(buzzer, LOW);
    
    lcd.setCursor(0,1);
    lcd.print(&quot;Temp: &quot;); 
    lcd.print(temp);
    lcd.println(&quot;Celcius&quot;);
    delay(2000); //Delay 2 sec between temperature/humidity check.
}

How to add relay and buzzer to close it with buzzer run on 65% humidity value?
In this code:
void loop()
{
   sample temp and humidity;
   display temp;
   display humidity;

   if humidity &lt;= 50
      LED on;
      buzzer on;
   else
      display temp
      wait 2 sec
   end


There is a missing '}' to to close the if/else.
Why do you display temp twice within the loop?
Where is the logic for the relay and the buzzer at 65%?
Pin numbers for the LED and the buzzer are undefined.
The LED and buzzer pins need to be set to OUTPUT mode in your setup() function.

If I understand your description, you probably need somethng like the following, in your loop function:
   if humidity &lt;= 50
      LED on;
      buzzer on;
   else if hum &gt;= 65%m
      close relay;
      buzzer on;
   end

When I have a problem with program logic that isn't obvious to me, I write it out in pseudo-code as I did above. Once I figure out the logic, then I'll type in C++ with proper syntax.
If I haven't understood your intentions in the above pseudo-code, I'd suggest you do the same thing, until you believe what you've written. Only then try to make it into working code.