fathiidriss رقيب
عدد الرسائل : 22 العمر : 54 تاريخ التسجيل : 26/06/2010
| موضوع: حضانة البيض تعمل بالاوردينو الثلاثاء 5 مارس 2019 - 15:06 | |
| مرحبا اقدم لكم هذا المشروع المجرب لبرنامج حضانة البيض بالاوردينو مرفق الملف مع برنامج تمثيلي بالبروتيوس التحميل من هذا الرابط https://www.4shared.com/rar/Z-pXVkCbee/__online.html /* برنامج فقاسة البيض * Fathi Idris ليبيا البيضاء الاول من مارس 2019 */ #include #include #include #define DHT11 A3 int addT = 0; int addH = 2; const int ok = A0; const int UP = A1; const int DOWN = A2; const int bulb = 6; const int vap = 5; const int roter = 4; const int rs = 12; const int en = 11; const int d4 = 10; const int d5 = 9; const int d6 = 8; const int d7 = 7; int ack = 0; int pos = 0; int sec = 0; int Min = 0; int hrs = 0; int T1 = 0; int T2 = 0; int TAverge = 0; int H1 = 0; int H2 = 0; int HAverge = 0; int T_threshold = EEPROM.read(addT); int H_threshold = EEPROM.read(addH); boolean Roter_begin = true; boolean T_condition = true; boolean H_condition = true; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); dht DHT; void setup() { pinMode(ok, INPUT); pinMode(UP, INPUT); pinMode(DOWN, INPUT); pinMode(bulb, OUTPUT); pinMode(vap, OUTPUT); pinMode(roter, OUTPUT); digitalWrite(bulb, LOW); digitalWrite(vap, LOW); digitalWrite(roter,LOW); digitalWrite(ok, HIGH); digitalWrite(UP, HIGH); digitalWrite(DOWN, HIGH); lcd.begin(16, 2); lcd.setCursor(5, 0); lcd.print("Digital"); lcd.setCursor(4, 1); lcd.print("Incubator"); delay(1000); } void loop() { //*************************** // set tempreture //************************** if (digitalRead(ok) == LOW)//DELAY 2 second { lcd.clear(); lcd.setCursor(0, 0); lcd.print("Set Temperature:"); lcd.setCursor(0, 1); lcd.print(T_threshold); lcd.print(" C"); delay(2000); while (T_condition) { if (digitalRead(UP) == LOW) { T_threshold = T_threshold + 1; lcd.clear(); lcd.setCursor(0, 1); lcd.print(T_threshold); lcd.print(" C"); EEPROM.write(addT, T_threshold); delay(500); } if (digitalRead(DOWN) == LOW) { T_threshold = T_threshold - 1; lcd.clear(); lcd.setCursor(0, 1); lcd.print(T_threshold); lcd.print(" C"); EEPROM.write(addT, T_threshold); delay(500); } if (digitalRead(ok) == LOW) { delay(1000); T_condition = false; } }
//********************************** // set humidity //*********************************
lcd.clear(); lcd.setCursor(0, 0); lcd.print("Set Humidity:"); lcd.setCursor(0, 1); lcd.print(H_threshold); lcd.print("%"); delay(100); while (H_condition) { if (digitalRead(UP) == LOW) { H_threshold = H_threshold + 1; lcd.setCursor(0, 1); lcd.print(H_threshold); lcd.print("%"); EEPROM.write(addH, H_threshold); delay(500); } if (digitalRead(DOWN) == LOW) { H_threshold = H_threshold - 1; lcd.setCursor(0, 1); lcd.print(H_threshold); EEPROM.write(addH, H_threshold); delay(500); } if (digitalRead(ok) == LOW) { delay(1000); H_condition = false;
} } } else{
ack = 0; int chk = DHT.read11(DHT11); switch (chk) {
//case DHTLIB_ERROR_CONNECT: ack = 1; break; } if (ack == 0) { T1 = DHT.temperature; delay(1000); T2 = DHT.temperature; TAverge = (T1 + T2)/2 ; H1 = DHT.humidity; delay(1000); H2 = DHT.humidity; HAverge =(H1 + H2)/2; lcd.clear(); lcd.setCursor(0, 0); lcd.print(" Temp:"); lcd.print(TAverge); lcd.print(":set ="); lcd.print(T_threshold); lcd.setCursor(0, 1); lcd.print("Humid:"); lcd.print(HAverge); lcd.print(":set ="); lcd.print(H_threshold);
if (TAverge > T_threshold) { digitalWrite(bulb, LOW); digitalWrite(vap, HIGH); }
if (TAverge == T_threshold) { digitalWrite(bulb, LOW); digitalWrite(vap , LOW); }
if ((HAverge > H_threshold)&(TAverge >=( T_threshold-2)) ) { digitalWrite(bulb, LOW); digitalWrite(vap, HIGH); } if (TAverge <= (T_threshold-1)) { digitalWrite(bulb, HIGH); digitalWrite(vap ,LOW); delay(5000); delay(5000); digitalWrite(bulb, HIGH); digitalWrite(vap , HIGH); delay(5000); delay(5000); delay(5000); }
T_condition = true; H_condition = true; delay(5000);
} //*********************************** //Firest Time Rotation //*********************************** while (Roter_begin) { digitalWrite(roter,HIGH); lcd.clear(); lcd.setCursor(0, 0); lcd.print("ROTER IS TURNNIG "); lcd.setCursor(1, 4); lcd.print(" (FIRST TURN) "); delay(5000); delay(5000); delay(5000); digitalWrite(roter,LOW); Roter_begin = false ;
} //************************************ // time for change position motor //*********************************** sec = sec + 5; lcd.clear(); lcd.setCursor(0, 0); lcd.print("TIME H : M : S "); lcd.setCursor(1, 6); lcd.print(" "); lcd.print(hrs); lcd.print(" : "); lcd.print(Min); lcd.print(" : "); lcd.print(sec); //****************** if (sec == 60) { sec = 0; Min = Min + 1; } if (Min == 60) { Min = 0; hrs = hrs + 1; } if (hrs == 8 && Min ==0 && sec ==0) { digitalWrite(roter,HIGH); lcd.clear(); lcd.setCursor(0, 0); lcd.print("ROTER IS TURNNIG "); lcd.setCursor(1, 4); lcd.print("ROTER SECOND TURN "); delay(5000); delay(5000); delay(5000); digitalWrite(roter,LOW); }
if (hrs == 16 && Min ==0 && sec ==0) { hrs = 0; digitalWrite(roter,HIGH); lcd.clear(); lcd.setCursor(0, 0); lcd.print("ROTER IS TURNNIG "); delay(5000); delay(5000); delay(5000); digitalWrite(roter,LOW); }
if (ack == 1) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("No Sensor data."); lcd.setCursor(0, 1); lcd.print("System Halted."); digitalWrite(bulb, LOW); digitalWrite(vap, LOW); } } } //END OF LOOp /*THIS PROGRAM WRITTEN BY FATHI IUDRIS ALBIEDA LIBYA 1/3/2019 */ |
https://www.4shared.com/rar/Z-pXVkCbeel | |
|