Cod Arduino
Cod Arduino
Cod Arduino
h>
#include "DHT.h"
#include <LiquidCrystal.h>
#define DHTPIN 0
#define relay A1
LiquidCrystal lcd(8,9,4,5,6,7);
int i=0;
//senzor ultrasonic
IRrecv irrecv(receiver);
decode_results results;
void setup(void) {
lcd.begin(16, 2);
lcd.print("Citire senzor");
dht.begin();
//pentru releu
pinMode(relay, OUTPUT);
digitalWrite(relay, HIGH);
pinMode(buzzer, OUTPUT);
//senzor ultrasonic
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
irrecv.enableIRIn();
void translateIR(){
switch(results.value)
v = v + 1;
lcd.print(v);
break;
v = v - 1;
lcd.print(v);
break;
case 0xFFE21D: //lcd.print("3");
lcd.setCursor(0,0);
lcd.clear();
lcd.print("Oprire Sistem!");
digitalWrite(relay, HIGH);
digitalWrite(relay_pin_bec,HIGH);
delay(20000);
break;
default:
Serial.println("Semnal necunoscut");
void loop() {
humidity = dht.readHumidity();
temperature = dht.readTemperature();
lcd.clear();
char tempF[6];
char humF[6];
dtostrf(temperature, 5, 1, tempF);
dtostrf(humidity, 2, 0, humF);
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
cm = (duration/2) / 29.1;
lcd.clear();
lcd.print("ATENTIE!!! ");
lcd.setCursor(0, 1);
lcd.print("Prea aproape!");
digitalWrite(relay, HIGH);
delay(55000);
if (temperature> v){
digitalWrite(relay, LOW);
digitalWrite(led_rosu,HIGH);
delay(200);
digitalWrite(led_verde ,LOW);
delay(200);
digitalWrite(relay, HIGH);
digitalWrite(led_verde ,HIGH);
delay(200);
digitalWrite(led_rosu,LOW);
delay(200);
lcd.print("T:");
lcd.print(tempF);
lcd.print((char)223);
lcd.print("C ");
lcd.print("H: ");
lcd.print(humF);
lcd.print("%");
lcd.setCursor(0, 1);
lcd.print("Temp setata:");
lcd.print(v);
//telecomanda
if (irrecv.decode(&results)){
translateIR();
irrecv.resume();
}
// sistem alarma - buzzer
if(temperature> 30){
lcd.clear();
lcd.print("ATENTIE!!! ");
lcd.setCursor(0, 1);
lcd.print("Temp Ridicata!");
tone(buzzer, 1000);
delay(10000);
noTone(buzzer);
delay(1000);
delay(1000);