- #include <OneWire.h>
- #include <DallasTemperature.h>
- //parsa_shams_ali_zadeh
- #define fan 5
- #define LDR A0
- #define output 2
- #define hiter 4
- OneWire oneWire(output);
- DallasTemperature sensors(&oneWire);
- void setup() {
- Serial.begin(9600);
- sensors.begin();
- pinMode(hiter,OUTPUT);
- pinMode(fan,OUTPUT);
- pinMode(7,OUTPUT);
- pinMode(8,OUTPUT);
- pinMode(9,OUTPUT);
- pinMode(10,OUTPUT);}
- void loop() {
- if (temp != DEVICE_DISCONNECTED_C){
- float temp = sensors.getTempCByIndex(0); sensors.requestTemperatures();
- Serial.print("Temperature hast: ");
- Serial.println(temp);
- if(temp < 30){
- digitalWrite(fan, LOW);
- digitalWrite(hiter, HIGH);}
- if(temp < 50 && temp > 30){
- digitalWrite(fan, LOW);
- digitalWrite(hiter, LOW);}
- if(temp >= 50){
- digitalWrite(fan, HIGH);
- digitalWrite(hiter, LOW);}}
- while(analogRead(LDR) >= 400){
- digitalWrite(7, 0);
- digitalWrite(8, 0);
- digitalWrite(9, 0);
- digitalWrite(10, 0);
- if(temp < 30){
- digitalWrite(fan, LOW);
- digitalWrite(hiter, 1=HIGH);}
- if(temp < 50 && temp > 30){
- digitalWrite(fan, LOW);
- digitalWrite(hiter, LOW);}
- if(temp >= 50){
- digitalWrite(fan, HIGH);
- digitalWrite(hiter, LOW);}}
- else{Serial.println("data eror dad ");}
- }
- }
Recent Pastes