Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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
- int motoPin = 1; // motoPin goes to a relay to power a 12v waterpump
- int fivPin = 2;
- int tenPin = 3; // input pins assigned pins and variables
- int fiftnPin = 4;
- int usrInput(); //initilize funtion
- void setup()
- {
- int j = 0;
- pinMode(motoPin, OUTPUT);
- pinMode(fivPin, INPUT);
- pinMode(tenPin, INPUT);
- pinMode(fiftnPin, INPUT);
- for (j = 0; j < 3; j++) //j is declared and used to iterate loop 3 times to signel boot and operational
- {
- digitalWrite(motoPin, HIGH);
- delay(500);
- digitalWrite(motoPin, LOW);
- delay(500);
- }
- delay(2000);
- }
- void loop()
- {
- int i = 0, n = 15; //set n defualt value to 15 so it rests for 15 minutes on defualt
- digitalWrite(motoPin, HIGH);
- 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
- {
- delay(1);
- n == usrInput( n );
- }
- digitalWrite(motoPin, LOW);
- for (i = 0; i < (n*60*1000); i++) //turn off and wait for n minutes before running again THIS IS THE WAIT PORTION
- {
- delay(1);
- n == usrInput ( n );
- }
- }
- int usrInput(int t) // this accepts user input as grounding out of pins on the IC
- {
- 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
- {
- t = 5;
- return t;
- }
- if (digitalRead(tenPin) == LOW)
- {
- t = 10;
- return t;
- }
- if (digitalRead(fiftnPin) == LOW)
- {
- t = 15;
- return t;
- }
- return t; // return the value of t to the function call
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement