Codice Arduino
Arduino Code

#include <DHT.h>
#include <LiquidCrystal.h>
#include "DHT.h"
#define DHTPIN 7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

//Libreria dell'LCD con i pin
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int redLed = 10;
int greenLed = 9;
int buzzer = 8;
int gas = A1;
int soglia = 500;

void setup() {
lcd.begin(16,2);

pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(gas, INPUT);
Serial.begin(9600);
Serial.println("CLEARDATA");
Serial.println("LABEL, time, valore gas, umidita, temperatura");
lcd.print("Apertura dati. .");
delay(5000);
lcd.clear();
}

void loop() {

int t = dht.readTemperature();
int h = dht.readHumidity();
int analogSensor = analogRead(gas);

if (analogSensor > soglia)
{
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
tone(buzzer, 1000, 200);
}
else
{
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
noTone(buzzer);
}

switch (((millis()/1000L)/3)%3) {

case 1:
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temperatura");
lcd.setCursor(13,0);
lcd.print(t);
lcd.setCursor(0,1);
lcd.print("Fumo");
lcd.setCursor(13,1);
lcd.print(analogRead(gas));
break;

case 2:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Umidita'");
lcd.setCursor(13, 0);
lcd.print(h);
lcd.setCursor(0,1);
lcd.print("Fumo");
lcd.setCursor(13,1);
lcd.print(analogRead(gas));
break;
}

lcd.setCursor(0,1);
lcd.print("Fumo");
lcd.setCursor(13,1);
lcd.print(analogRead(gas));

Serial.print("DATA, TIME,");
Serial.print(analogSensor);
Serial.print(" , ");
Serial.print(h);
Serial.print(" , ");
Serial.println(t);

delay(500);
}


QUESTO SITO È STATO CREATO TRAMITE