- #include <dht11.h>
- #define DHT11PIN 4
- dht11 DHT11;
- int gasPin = A0;
- int threshold = 400;
- int buzzerPin = 2;
- int pirPin = 7;
- int ledPin = 11;
- void setup() {
- Serial.begin(9600);
- pinMode(gasPin, INPUT);
- pinMode(buzzerPin, OUTPUT);
- pinMode(pirPin, INPUT);
- pinMode(ledPin, OUTPUT);
- }
- void loop() {
- int gasValue = analogRead(gasPin);
- int chk = DHT11.read(DHT11PIN);
- int pirState = digitalRead(pirPin);
- Serial.print("Humidity (%): ");
- Serial.println((float)DHT11.humidity, 2);
- Serial.print("Temperature (C): ");
- Serial.println((float)DHT11.temperature, 2);
- Serial.print("Gas Value: ");
- Serial.println(gasValue);
- if (gasValue > threshold) {
- digitalWrite(buzzerPin, HIGH);
- } else {
- digitalWrite(buzzerPin, LOW);
- }
- if (pirState == HIGH) {
- digitalWrite(ledPin, HIGH);
- Serial.println("Motion detected!");
- } else {
- digitalWrite(ledPin, LOW);
- Serial.println("No motion detected.");
- }
- Serial.println("--------------------------------------------");
- delay(1000);
- }
[text] hi
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: