Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. int motorPin = A0; // pin that turns on the motor
  2. int blinkPin = 13; // pin that turns on the LED
  3. int watertime = 5; // how long to water in seconds
  4. int waittime = 60; // how long to wait between watering, in minutes
  5.  
  6. void setup()
  7. {
  8.     pinMode(motorPin, OUTPUT); // set A0 to an output so we can use it to turn on the transistor
  9.     pinMode(blinkPin, OUTPUT); // set pin 13 to an output so we can use it to turn on the LED
  10. }
  11.  
  12. void loop()
  13. {
  14.     digitalWrite(motorPin, HIGH); // turn on the motor
  15.     digitalWrite(blinkPin, HIGH); // turn on the LED
  16.     delay(watertime*1000);        // multiply by 1000 to translate seconds to milliseconds
  17.  
  18.     digitalWrite(motorPin, LOW);  // turn off the motor
  19.     digitalWrite(blinkPin, LOW);  // turn off the LED
  20.     delay(waittime*60000);        // multiply by 60000 to translate minutes to milliseconds
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement