Advertisement
Guest User

blink board

a guest
Jun 17th, 2020
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>   // not sure if i used anything from this library or really what library I do even need, will remove and retest if program functions correctly
  2.  
  3. int motoPin = 1;    // motoPin goes to a relay to power a 12v waterpump
  4. int fivPin = 2;
  5. int tenPin = 3;        // input pins assigned pins and variables
  6. int fiftnPin = 4;
  7.  
  8. int usrInput();     //initilize funtion
  9.  
  10. void setup()      
  11. {
  12.   int j = 0;        
  13.   pinMode(motoPin, OUTPUT);
  14.   pinMode(fivPin, INPUT);
  15.   pinMode(tenPin, INPUT);
  16.   pinMode(fiftnPin, INPUT);
  17.   for (j = 0; j < 3; j++)    //j is declared and used to iterate loop 3 times to signel boot and operational
  18.   {
  19.     digitalWrite(motoPin, HIGH);    
  20.     delay(500);
  21.     digitalWrite(motoPin, LOW);
  22.     delay(500);
  23.   }
  24.   delay(2000);
  25. }
  26. void loop()
  27. {
  28.   int i = 0, n = 15;    //set n defualt value to 15 so it rests for 15 minutes on defualt
  29.   digitalWrite(motoPin, HIGH);
  30.     for (i = 0; i < 30000; i++)   // for 1 minute (1ms* 60*1000) run pump and look for input from usrInput function THIS IS THE RUN PORTION
  31.     {
  32.       delay(1);
  33.       n == usrInput( n );
  34.     }
  35.    digitalWrite(motoPin, LOW);
  36.     for (i = 0; i < (n*60*1000); i++)  //turn off and wait for n minutes before running again THIS IS THE WAIT PORTION
  37.     {
  38.       delay(1);
  39.       n == usrInput ( n );
  40.     }
  41. }
  42.  
  43. int usrInput(int t)   // this accepts user input as grounding out of pins on the IC
  44. {
  45.  if (digitalRead(fivPin) == LOW)      //if the five minute (or any input pin) delay pin is grounded during this funtion, set the value of t to 5 (or other according value) and iterate the wait loop for that long in minutes
  46.   {
  47.     t = 5;
  48.     return t;
  49.   }
  50.   if (digitalRead(tenPin) == LOW)
  51.   {
  52.     t = 10;
  53.     return t;
  54.   }
  55.   if (digitalRead(fiftnPin) == LOW)
  56.   {
  57.     t = 15;
  58.     return t;
  59.   }
  60.   return t;  // return the value of t to the function call
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement