TEXT 235
Parsa_Shams2 Guest on 22nd December 2023 08:37:21 PM
  1. #include <OneWire.h>
  2. #include <DallasTemperature.h>
  3. //parsa_shams_ali_zadeh
  4. #define fan 5
  5. #define LDR A0
  6. #define output 2
  7. #define hiter 4
  8. OneWire oneWire(output);
  9. DallasTemperature sensors(&oneWire);
  10. void setup() {
  11.   Serial.begin(9600);
  12.   sensors.begin();
  13.   pinMode(hiter,OUTPUT);
  14.   pinMode(fan,OUTPUT);
  15.   pinMode(7,OUTPUT);
  16.   pinMode(8,OUTPUT);
  17.   pinMode(9,OUTPUT);
  18.   pinMode(10,OUTPUT);}
  19. void loop() {
  20.   if (temp != DEVICE_DISCONNECTED_C){
  21. float temp = sensors.getTempCByIndex(0);  sensors.requestTemperatures();
  22.        Serial.print("Temperature hast: ");
  23.        Serial.println(temp);
  24.       if(temp < 30){
  25.         digitalWrite(fan, LOW);
  26.         digitalWrite(hiter, HIGH);}
  27.   if(temp < 50 && temp > 30){
  28.         digitalWrite(fan, LOW);
  29.         digitalWrite(hiter, LOW);}
  30.   if(temp >= 50){
  31.         digitalWrite(fan, HIGH);
  32.         digitalWrite(hiter, LOW);}}
  33.   while(analogRead(LDR) >= 400){
  34.       digitalWrite(7, 0);
  35.       digitalWrite(8, 0);
  36.       digitalWrite(9, 0);
  37.       digitalWrite(10, 0);
  38.   if(temp < 30){
  39.         digitalWrite(fan, LOW);
  40.         digitalWrite(hiter, 1=HIGH);}
  41.   if(temp < 50 && temp > 30){
  42.         digitalWrite(fan, LOW);
  43.         digitalWrite(hiter, LOW);}
  44.   if(temp >= 50){
  45.         digitalWrite(fan, HIGH);
  46.         digitalWrite(hiter, LOW);}}
  47.         else{Serial.println("data eror dad ");}
  48. }
  49. }

Hightechrobo bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.