const int buzzer=10; //buzzer to arduino 10
//Libraries
//include DHT 22 library code
#include <DHT.h>
//include LCD library code
#include <LiquidCrystal.h>
//initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12,11,5,4,3,2);
//Constants
#define DHTPIN 9 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
void setup()
{
Serial.begin(9600);
dht.begin();
//set up the LCD's number of columns
lcd.begin(16,2);
// put your setup code here, to run once:
pinMode(buzzer, OUTPUT); //Set buzzer - pin 10 as an output
}
void loop()
{
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp= dht.readTemperature();
//Print temp and humidity values to serial monitor
lcd.print("Hum : ");
lcd.print(hum);
lcd.print(" % ");
lcd.setCursor(0, 1);
lcd.print("Temp: ");
lcd.print(temp);
lcd.println(" Cel ");
delay(2000); //Delay 2 sec.
if (hum >= 60 && temp <=25.4)
{
// put your main code here, to run repeatedly:
tone(buzzer, 1000);//send 1KHz sound signal
delay(1000); //..for 1 sec
noTone(buzzer); //Stop sound...
delay(1000); //..for l sec
}
}