Boby360

Untitled

Dec 17th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. const int VAL_PROBE = 0; //Analog pin 0
  2. const int MOISTURE_LEVEL = 450; // the value after the LED goes on
  3.  
  4. void setup()
  5. {
  6. Serial.begin(9600);
  7. pinMode(13, OUTPUT);
  8. pinMode(7, OUTPUT);
  9.  
  10. }
  11.  
  12. void loop()
  13. {
  14. digitalWrite(13,HIGH);
  15. delay(2000);
  16. int moisture = analogRead(VAL_PROBE);
  17.  
  18. Serial.print("Moisture = ");
  19. Serial.println(moisture);
  20.  
  21. if(moisture < MOISTURE_LEVEL)
  22. {
  23. digitalWrite(7,LOW);
  24. digitalWrite(13,LOW);
  25. delay(10000);
  26. }
  27. else
  28. {
  29. digitalWrite(7,HIGH);
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment