CPP 244
Parsa_shams Guest on 22nd December 2023 08:09:47 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.   sensors.requestTemperatures();
  21.   float temp = sensors.getTempCByIndex(0);
  22.   if (temp != DEVICE_DISCONNECTED_C){
  23.        Serial.print("Temperature hast: ");
  24.        Serial.println(temp);
  25.       if(temp < 30){
  26.         digitalWrite(fan, LOW);
  27.         digitalWrite(hiter, HIGH);}
  28.   if(temp < 50 && temp > 30){
  29.         digitalWrite(fan, LOW);
  30.         digitalWrite(hiter, LOW);}
  31.   if(temp >= 50){
  32.         digitalWrite(fan, HIGH);
  33.         digitalWrite(hiter, LOW);}}
  34.   while(analogRead(LDR) >= 400){
  35.       digitalWrite(7, 0);
  36.       digitalWrite(8, 0);
  37.       digitalWrite(9, 0);
  38.       digitalWrite(10, 0);
  39.   if(temp < 30){
  40.         digitalWrite(fan, LOW);
  41.         digitalWrite(hiter, 1=HIGH);}
  42.   if(temp < 50 && temp > 30){
  43.         digitalWrite(fan, LOW);
  44.         digitalWrite(hiter, LOW);}
  45.   if(temp >= 50){
  46.         digitalWrite(fan, HIGH);
  47.         digitalWrite(hiter, LOW);}}
  48.         else{Serial.println("data eror dad ");}
  49. }
  50. }

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.