Advertisement
Ogomegbunam

Poultry illuminator

Mar 31st, 2024
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | Housing | 0 0
  1. #define Re 4
  2.  
  3. #define LDR A0
  4.  
  5. void setup() {
  6. // put your setup code here, to run once:
  7. Serial.begin(9600);
  8. pinMode(Re,OUTPUT);
  9. pinMode(LDR,INPUT);
  10.  
  11. }
  12. void(* resetFunc) (void) = 0; //declare reset function @ address 0
  13.  
  14. void loop() {
  15. Serial.print("Secs: ");
  16. Serial.println(millis() / 1000);
  17.  
  18. int ldr = analogRead(LDR);
  19. Serial.print("Strength: ");
  20. Serial.println(ldr);
  21.  
  22. if (ldr <= 3){
  23.  
  24. if ((millis()/1000) == 0){
  25. digitalWrite (Re,LOW);
  26. }
  27.  
  28. if ((millis()/1000) == 3600){
  29. digitalWrite (Re,HIGH);
  30. }
  31.  
  32. if ((millis()/1000) == 14400){
  33. Serial.println("resetting");
  34. resetFunc(); //call reset
  35.  
  36. delay(100);
  37. }
  38. }
  39.  
  40. if (ldr >4){
  41. digitalWrite(Re,HIGH);
  42. delay(5000);
  43. resetFunc(); //call reset
  44.  
  45. delay(5000);
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement