Multiple Timer values on one output

Is there a way to address multiple timer values to one output pin? This is my process that I want to control, I will use blinking an LED as an example.I am new to Arduino programming and my expertise is in mechanical design so please don't carve me up to bad with my bad programming knowledge. I am in over my head but need to get this project working since my programmer that was on this project has bailed on me . I have had other post on this same project and have gotten great help but as with all projects the programming side has continued to evolve and I am finding myself needing more help. Learning a great deal as this project develops.

Thanks in advance !

JWalt

LED on pin 6
LED on pin 7

At program start LED on pin 7 goes high
LED on PIN 7 stays high for (X) amount of time
After time has elapsed PIN 7 goes LOW
Delay () seconds
LED on pin 6 goes high
Delay () seconds
LED on pin 6 goes low
loop back to beginning

OK now after 5 loops of this simple program I want to change the delay value of pin 6 on time
nothing else changes but this on time .

After 5 more cycles I want to change the delay value again

5 more cycles change again

5 more cycles change again

5 more cycles change again

Then I would like to put a counter that halts the program after lets say the 22 cycle.

Can you assign multiple delays to one pin?

lets say

const int PIN6 = 6

const unsigned long pin6_interval1 = 2000
const unsigned long pin6_interval2 = 2010
const unsigned long pin6_interval3 = 2020

and so on

then create" interval " loops "

void interval1 ()
{ "perform sequence of events as described above"

void interval2 ()

and so on

then in the void loop

call the proper interval based on count conditions.

if (count conditions)

interval1 // How do you make this call?
if (count conditions)
interval2

and so on

else

(count conditions)
// End of program until reset
PIN6 = LOW
PIN7 = LOW

something like the following?

you'll need to write the LED7on() and LED6() functions

void loop()
{
    int numLoops = 22;
    int x = 1000;
    int y = 1000;
    int z = 1000;

    for (int i = 0; i <= numLoops; i++)
    {
        LED7on(true);
        delay(X);
        LED7on(false);
        delay(y);
        LED6on(true);
        delay(z);
        LEDon(false);

        
        if (i == 4)
	{
	    //change delay after 5 loops
            z = 2000;
        }
        elseif (i == 9)
        {
            //change delay after 10 loops
            z = 3000;
        }
        elseif (i == 14)
	{
            //change delay after 15 loops
            z = 4000;
        }
    }
}

Ok Here is what I have come up with using an example that I found and applied to my process. Please don't laugh to loud but it does compile and it makes sense to me with my limited knowledge. I think that I have got an issue with the code actually turning the stirring motor back on but haven't uploaded the code to the actual board yet to test. One thing that I forgot to say in my first post is that I need the stirring motor to run for the delay value at the bottom of the code and then shut off and start the loop. Once the maxnum that I declared has been reached that is when I want the program to stop.
You will see that I put a "while" statement at the end of the void loop if I give it a value (1) is that all I need to do to stop the program at the max number or does that just execute the loop 1 time ?

Thanks for the quick reply I will look at your code and try to understand what is going on.

Thanks, Again !


/*
  Feeding System Delivery code based on time
  Pin 5 connected to pinch valve solid state relay
  Pin 7 connected to stirring motor solid state relay






  25 Nov. 2014

 */
#include <LiquidCrystal.h>
// Define LCD pins
LiquidCrystal lcd (12, 11, 3, 2, 1, 0);
const int pinchPin = 5;
const int motorPin = 7;
int maxnum = 25;
int count = 0;
// assigning delays
const unsigned long pinchPin_feed1 = 2000;
const unsigned long pinchPin_feed2 = 2012;
const unsigned long pinchPin_feed3 = 2024;
const unsigned long pinchPin_feed4 = 2036;
const unsigned long pinchPin_feed5 = 2050;

// declaring variables for timers
unsigned long feed1_timer;
unsigned long feed2_timer;
unsigned long feed3_timer;
unsigned long feed4_timer;
unsigned long feed5_timer;







void setup() {
  // initialize digital pins 5,7 as an output.
  // initialize digital pin 6 as an input.
  pinMode(pinchPin, OUTPUT);
  //pinMode(startPin,INPUT);
  pinMode(motorPin, OUTPUT);
  feed1_timer = millis ();
  feed2_timer = millis ();
  feed3_timer = millis ();
  feed4_timer = millis ();
  feed5_timer = millis ();


  lcd.begin(16, 2);

}
// feeding sequence calls
void toggle_feed1 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (5000);
  digitalWrite (pinchPin, HIGH);
  feed1_timer = millis ();
}

void toggle_feed2 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (5000);
  digitalWrite (pinchPin, HIGH);
  feed2_timer = millis ();
}

void toggle_feed3 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (5000);
  digitalWrite (pinchPin, HIGH);
  feed3_timer = millis ();
}

void toggle_feed4 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (5000);
  digitalWrite (pinchPin, HIGH);
  feed4_timer = millis ();
}

void toggle_feed5 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (5000);
  digitalWrite (pinchPin, HIGH);
  feed5_timer = millis ();
}


void loop() {

  lcd.setCursor(2, 0);
  lcd.print("# OF FEEDINGS");
  lcd.setCursor(7, 1);
  lcd.print(count);

  //calling of feed1 time
  if ((millis() - feed1_timer) >= pinchPin_feed1 && count <= 5)
    toggle_feed1 ();

  //calling of feed2 time
  if ((millis() - feed2_timer) >= pinchPin_feed2 && count >= 5 & count <= 10 )
    toggle_feed2 ();

  //calling of feed3 time
  if ((millis() - feed3_timer) >= pinchPin_feed3 && count >= 10 & count <= 15 )
    toggle_feed3 ();

  //calling of feed4 time
  if ((millis() - feed4_timer) >= pinchPin_feed4 && count >= 15 & count <= 20 )
    toggle_feed4 ();

  //calling of feed5 time
  if ((millis() - feed5_timer) >= pinchPin_feed5 && count >= 20 & count <= 25 )
    toggle_feed5 ();


  delay (65 * 60000UL);           //stirring motor run time set to 1hr5min

  count++;                   //count the number of feedings

}


//while (0);

If you want to have more than one thing controlled by time then you MUST stop using the delay() function and use millis() for timing. The demo several things at a time illustrates how.

The delay() function prevents the Arduino from doing anything else until the period expires.

Unfortunately that will require fairly significant changes to your code.

...R

Ok I have coded myself into a corner and need some help. Can someone tell me why I am not calling my delay times that I have declared. If I remove the feedtimer millis and put delays in there place the code functions the way I want it to. I just can't seem to get my head wrapped around the millis function to get it working properly. I really don't want to use delays because I want to be able to change the values at the top of the code instead of scrolling thru the code to change delay values.
I really don't need to have anything else happen during each feeding cycle as this is a purely sequential process. Please can someone explain to me what I am doing wrong here.

Thanks !!


/*
  Feeding System Delivery code based on time
  Pin 5 connected to pinch valve solid state relay
  Pin 7 connected to stirring motor solid state relay






  25 Nov. 2014

 */
#include <LiquidCrystal.h>
// Define LCD pins
LiquidCrystal lcd (12, 11, 3, 2, 1, 0);
const int pinchPin = 5;
const int motorPin = 7;
int maxnum = 25;
int count = 0;
// assigning delays
const unsigned long pinchPin_feed1 = 2000;
const unsigned long pinchPin_feed2 = 2012;
const unsigned long pinchPin_feed3 = 2024;
const unsigned long pinchPin_feed4 = 2036;
const unsigned long pinchPin_feed5 = 2050;

// declaring variables for timers
unsigned long feed1_timer;
unsigned long feed2_timer;
unsigned long feed3_timer;
unsigned long feed4_timer;
unsigned long feed5_timer;







void setup() {
  // initialize digital pins 5,7 as an output.
  // initialize digital pin 6 as an input.
  pinMode(pinchPin, OUTPUT);
  //pinMode(startPin,INPUT);
  pinMode(motorPin, OUTPUT);
  feed1_timer = millis ();
  feed2_timer = millis ();
  feed3_timer = millis ();
  feed4_timer = millis ();
  feed5_timer = millis ();


  lcd.begin(16, 2);

}
// feeding sequence calls
void toggle_feed1 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (5000);
  digitalWrite (pinchPin, HIGH);
  feed1_timer = millis ();
}

void toggle_feed2 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (5000);                //delay needed for motor to stop nothing else needs to happen during this delay
  digitalWrite (pinchPin, HIGH);
  feed2_timer = millis ();
}

void toggle_feed3 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (5000);
  digitalWrite (pinchPin, HIGH);
  feed3_timer = millis ();
}

void toggle_feed4 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (5000);
  digitalWrite (pinchPin, HIGH);
  feed4_timer = millis ();
}

void toggle_feed5 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (5000);
  digitalWrite (pinchPin, HIGH);
  feed5_timer = millis ();
}


void loop() {

  lcd.setCursor(2, 0);
  lcd.print("# OF FEEDINGS");
  lcd.setCursor(7, 1);
  lcd.print(count);

  //calling of feed1 time
  if ((millis() - feed1_timer) >= pinchPin_feed1 && count <= 5)
    toggle_feed1 ();

  //calling of feed2 time
  if ((millis() - feed2_timer) >= pinchPin_feed2 && count >= 5 & count <= 10 )
    toggle_feed2 ();

  //calling of feed3 time
  if ((millis() - feed3_timer) >= pinchPin_feed3 && count >= 10 & count <= 15 )
    toggle_feed3 ();

  //calling of feed4 time
  if ((millis() - feed4_timer) >= pinchPin_feed4 && count >= 15 & count <= 20 )
    toggle_feed4 ();

  //calling of feed5 time  
  if ((millis() - feed5_timer) >= pinchPin_feed5 && count >= 20 & count <= 25 )
    toggle_feed5 ();
    
    digitalWrite (motorPin,HIGH);


  delay (65 * 60000UL);           //stirring motor run time set to 1hr5min

  count++;                   //count the number of feedings

}


//while (0);

I can't quite figure what you are trying to do - especially what is the role of the variable count

I have revised one of your functions to make its logic more self contained - but I have omitted the references to count as I don't know how to use them.

This revised function would be called from loop() like this (subject to mods to deal with count)
I prefer to capture the value of millis() at the start of loop() and then use the same value throughout the loop.

void loop() {
   currentMills = millis();
   toggle_feed4();
}

void toggle_feed4 () {
    if (currentMillis - feed4_timer >= pinchPin_feed4) {
        feed4StartMillis = currentMillis;
        if (digitalRead (motorPin) == HIGH) {
            digitalWrite (motorPin, LOW);
        }
    }
    if (currentMillis  - feed4StartMillis >= 5000) {
        digitalWrite (pinchPin, HIGH);
        feed4_timer = currentMillis;
    }
}

Usual caveats - not compiled and not tested

...R

Edited to remove the ; at the end of the IF statement as pointed out in Reply #6. I had not spotted that error.

if (digitalRead (motorPin) == HIGH);

That line and others like it do nothing because it ends in a ;
When you use an if the next statement only is executed, the ; tells the compiler that the next statement has been reached.
If you want to do more than one statement then enclose it in braces { and }

Mind you the rest of that code is rubbish anyway, having a one and a half hour delay in the middle of checking if two second timers have timed out is not going to work.

Thanks Robin2 for your input and help. I am in way over my head but like I said in a previous post my programmer bailed on me. The counting is to determine what feed cycle that needs to be implemented. I think I need to explain the process so that everyone that has replied can understand what I am trying to accomplish.
I have built an automatic feeding unit to dispense liquid formula for a live stock application. I have a container that holds liquid formula and I dispense it through Arduino controlled valve, there is also a stirring motor that is controlled by the Arduino that shuts off before dispensing. So the logic is as follows.

Program Start:

Stirring Motor off

wait 5 sec for motor to stop

Pinch valve on (dispensing formula)

pinch valve on for 2 sec ( feed 1)

Pinch valve off

Stirring Motor On

Wait 1hr 5min for next cycle then start process over again, Do this (x)"maxnum" number of times then stop.

Now the counting is to count the total number of cycles (count++) displayed on LCD

But the count in the if statements is to know when to toggle to the next feeding process.

That is after the first 5 cycles and on the 6th cycle I need to adjust the pinch valve on time to compensate for loss in static water column pressure in the container.

i.e. feed2 time is now 2012ms instead of 2000ms, and so on every five feedings until I reach the max number of feedings and then the program stops.

I don't know how to implement the 1hr 5 min time any differently than a delay. One thing to note nothing else needs to happen when the delays are happening this is a totally sequential process.
I pieced this code together so that my feed time values for the pinch valve would be easy to find for value changes as once I get this code working I will have hours calibrating the system with timer changes and didn't want to scroll through lines of code to make these changes.

Thanks to all that have helped!

JWalt

The following questions and comments arose when I tried to understand your project based on your comments and the program in Reply #4

  1. I can't see where the motor is switched on.

  2. You seem to have 5 different outlets - and as there is only one motor I presume they all come from the same tank.

  3. I can't figure whether the outlets supply formula to 5 different locations, or all to the same location.

  4. Dispensing the formula involves opening a valve for a certain time and then closing it.

  5. You want the formula to be dispensed at intervals

  6. I can't figure why there appear to be different times for different outlets - or how those times fit into the longer time schedule that seem to repeat after 65 minutes.

  7. I can't make sense of your counting arrangements. Are you saying you want (eg) to dispense 5 doses of formula every 65 minutes? Does that mean that you want to issue 5 doses from each outlet?

  8. Why is there an overall limit on the number of doses?

I suspect the code I suggested goes a long way to meet your requirement.

You can easily use the millis() technique to manage a 65 minute period. However be aware that for long periods the Arduino is not as accurate as a clock. If that matters you will need to add a Real Time Clock (RTC) module.

It would be good if you can comment on all of the 8 numbered points.

...R

Robin2

Here are my answers sorry that I haven't been clear with my explanation I am trying to juggle the mechanical design of this project with this coding issue so I have a lot of things on my plate right now.

  1. I can't see where the motor is switched on.

Sorry I added the code after I posted it here I just put a digitalWrite statement before the long time delay at the bottom of the void loop

  1. You seem to have 5 different outlets - and as there is only one motor I presume they all come from the same tank.

No I have one valve(outlet) and one motor on one tank

  1. I can't figure whether the outlets supply formula to 5 different locations, or all to the same location.

the five different feeding times are for one outlet at one location

  1. Dispensing the formula involves opening a valve for a certain time and then closing it.

yes the time values of 2000ms thru 2050ms are the open times for the valve (pinchPin)"sorry not very clear on what this is"

  1. You want the formula to be dispensed at intervals

yes that is the 1hr. 5min delay, in other words every 65 min I want to dispense formula for (x) time based on how many cycles we have done.

  1. I can't figure why there appear to be different times for different outlets - or how those times fit into the longer time schedule that seem to repeat after 65 minutes.

Ok the different times are to allow for viscosity change in the formula. so after the first five feedings I need to increase the valve open time because the formulas viscosity has changed.

feed1 time for the first 5 feedings feed2 for the next five and so on

  1. I can't make sense of your counting arrangements. Are you saying you want (eg) to dispense 5 doses of formula every 65 minutes? Does that mean that you want to issue 5 doses from each outlet?

No I want to dispense five feedings 65min apart at the first valve open time (2000), then feedings 6-10 at valve open time (2012)or something like that and then 11-15 etc. remember I am compensating for viscosity change because of the long duration between feedings.

  1. Why is there an overall limit on the number of doses?

This whole project is based on feeding amount per day. the interval between feedings may change and so might the number of feedings. I need the program to stop at the required number of feedings because we do not want to feed more than the daily amount for that 24 hr period. this unit will be running 24 hrs. so it will not be monitored by a human all of the time. I have to put more formula in the container than what is required for the day to keep my static water pressure so that it will continue to dispense when the formula viscosity thickens.

Whew! that was windy but hope that answered your questions. If it is not asking to much if you could please give a brief explanation of how and why to made changes to my code I can't say thank you enough. I really want to learn as I see so many future projects involving an Arduino

Many Thanks!!!

JWalt

I don't know how to implement the 1hr 5 min time any differently than a delay.

Imagine for a moment that you were doing it manually. You wouldn't stand still and stare at the clock for 1 hour and 5 minutes would you? You would go do something else. Apply that paradigm to your code. Do something else, and periodically check if the time is up.

JWalt:
Robin2

Here are my answers

Ok, that seems to add a huge amount of essential information. I don't have time to consider it now but will try to look at it tonight.

...R

Ok, let me try to describe how I would organize the program

There is one valve - controlled by valvePin = I/O pinNumber

There is one motor - controller by motorPin = PPP

Normally the motor is running unless formula is to be dispensed

The valve must not be opened until X seconds after the motor is stopped
X is 5

One dose of formula is dispensed every 65 minutes

The first 5 doses have a valve open duration of T + 0t
The next 5 have a duration of T+t
The next 5 have a duration of T + 2t
up to t + 4t

T = 2000 and t = 12 - from your program

There is a max of 25 doses within 24 hrs

Note that there are only 22 x 65 minute periods in 24 hrs so there can't be 25 doses

The following code is a development of the piece I showed earlier. I think it will do what you want - but there may be silly mistakes in it.

void dispenseFormula () {
	
	formulaTimesAdjust = formulaCount / 5; // integer arithmetic
	formulaDurationMillis = formulaBaseMillis + formulaAdjustMillis * formulaTimesAdjust;
	
	if (currentMillis - prevFormulaMillis >= formulaIntervalMillis) {
		previousFormulaMillis += formulaIntervalMillis;
		motorOffMillis = currentMillis;
		digitalWrite (motorPin, LOW);
		formulaStarted = true;
	}
	if (currentMills - motorOffMillis >= motorWaitMillis && formulaStarted == true) {
		formulaStartMillis = currentMillis;
		digitalWrite(pinchPin, HIGH); // valve open
		valveStarted == true;
		formulaStarted == false;
		
	if (currentMillis  - formulaStartMillis >= formulaDurationMills && valveStarted == true)  {
		digitalWrite (pinchPin, LOW); // valve closed
		digitalWrite(motorPin, HIGH); // motor on
		formulaCount ++;
		valveStarted = false;
	}
}

...R

Wow this is by me. I do like the way you have organized things and yes there are only 22 cycles @ 65 min but knowing the professors that will be using this system I put some extra cycles knowing they would come up with some goofie feeding cycle. Now do I get rid of all my unsigned longs in my setup ? And just declare int I have a long thanksgiving weekend so I will give it a shot on setting up the program and see if it runs. May need some advise on my setup but let me give it a shot.

Thanks Robin2 for the help lets see if I can put the whole thing together.

JWalt

JWalt:
Now do I get rid of all my unsigned longs in my setup ?

I presume you meant to say "before setup()"
Get rid of the ones you don't need. You probably need to add new ones as required in the code I suggested. I assumed you would know how to create the necessary global variable to make my code work. All variables connected with millis() need to be unsigned long.

...R

Yes I did mean that I am going to try and figure out everything this weekend. I must say that this is way beyond my experience but the only way for me to learn is to roll up my sleeves and jump in.

Time will tell, once again thanks for everything that you have done . I am up to my elbows in alligators trying to get both ends of this project working with a completion deadline looming closer and closer every day.

Thanks again!

J Walt

There may well be silly errors in my code but it will be easier if you ask whatever questions are necessary to get it working rather than make random changes in the hope that something will work.

...R

I understand what you are saying, let me see how I progress later today and I can't say tank you enough with all of your help. I really want this to be a learning experience but I know this is way over my head.

Thanks!

JWalt

Hello Robin2

Well I am lost, your code is way past me ,I am swimming with the sharks and not going anywhere. My intent was not to have someone write this code for me but I will not get this going with your code so I took my original code and using delays this code is doing what I need.
Now not ignoring what you and the other people that have replied have said I just don't have the understanding of how to set things up and get your code working. I will post my code so if anyone wants to continue to educate me I will appreciate it .

Thanks to all that have replied I have gained a lot in my quest to learn.

Please note that the delay times are different since my first posting I need to get 22 feedings in 6 hrs for testing.

JWalt


/*
  Feeding System Delivery code based on time
  Pin 5 connected to pinch valve solid state relay
  Pin 7 connected to stirring motor solid state relay






  25 Nov. 2014

 */
#include <LiquidCrystal.h>
// Define LCD pins
LiquidCrystal lcd (12, 11, 3, 2, 1, 0);
const int pinchPin = 5;
const int motorPin = 7;
int maxnum = 22;
int count = 0;






void setup() {
  // initialize digital pins 5,7 as an output.
  // initialize digital pin 6 as an input.
  pinMode(pinchPin, OUTPUT);
  //pinMode(startPin,INPUT);
  pinMode(motorPin, OUTPUT);
  

  lcd.begin(16, 2);

}
// feeding sequence calls
void toggle_feed1 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (3000);
  digitalWrite (pinchPin, HIGH);
  //feed1_timer = millis ();
  delay (2050);
  digitalWrite (pinchPin, LOW);
}

void toggle_feed2 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (3000);
  digitalWrite (pinchPin, HIGH);
  //feed2_timer = millis ();
   delay (2100);
  digitalWrite (pinchPin, LOW);
}

void toggle_feed3 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (3000);
  digitalWrite (pinchPin, HIGH);
  //feed3_timer = millis ();
   delay (2150);
  digitalWrite (pinchPin, LOW);
}

void toggle_feed4 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (3000);
  digitalWrite (pinchPin, HIGH);
  //feed4_timer = millis ();
   delay (2200);
  digitalWrite (pinchPin, LOW);
}

void toggle_feed5 ()
{
  if (digitalRead (motorPin) == HIGH);
  digitalWrite (motorPin, LOW);
  delay (3000);
  digitalWrite (pinchPin, HIGH);
  //feed5_timer = millis ();
   delay (2250);
  digitalWrite (pinchPin, LOW);
}


void loop() {

  lcd.setCursor(2, 0);
  lcd.print("# OF FEEDINGS");
  lcd.setCursor(7, 1);
  lcd.print(count);

  //calling of feed1 time
  {
  if ( count <= 5)
    toggle_feed1 ();
  }
  //calling of feed2 time
  {
  if ( count >= 6 & count <= 10 )
    toggle_feed2 ();
  }
  //calling of feed3 time
  {
  if ( count >= 11 & count <= 15 )
    toggle_feed3 ();
  }
  //calling of feed4 time
  {
  if( count >= 16 & count <= 20 )
    toggle_feed4 ();
  }
  //calling of feed5 time 
 { 
  if ( count >= 21 & count <= 22 )
    toggle_feed5 ();
 }
  digitalWrite (motorPin,HIGH);
 {
   if(count >22)
   digitalWrite (motorPin,LOW);
   digitalWrite (pinchPin,LOW);
 }
   


  delay (16.4*60000UL);           //stirring motor run time set to 1hr5min

  count++;                   //count the number of feedings

}


//while (0);

sorry i know this is late, post but thinking could help others might be looking also for solution,

you can use my timer library, very simple to use. no delays, small footprint.

after you import the library, check the sample and test it.

/*
      Title: Simple Switch Timer
      Library: sstimer.ino
      Description: 
      Created Date: January 17, 2015
      Created By: Rolly Falco Villacacan
      Released into the public domain.
      http://www.mvsadnik.com/microcontrollers/
      https://www.facebook.com/groups/pinoymikrocontrollerscommunity/
      https://www.facebook.com/pages/Pinoy-Mikro-Controllers-Community/1397572657207414
*/

#include <sstimer.h>

//WATER_PUMP SETUP
int PIN_NO1 = 13;
long unsigned OFF_DURATION = 500; //in milliseconds HOW LONG YOU WANT THE PIN TO BE OFF STATE
long unsigned ON_DURATION = 500; //in milliseconds //HOW LONG YOU WANT THE PIN TO BE ON STATE

//LIGHTHING SETUP
int PIN_NO2 = 12;
long unsigned OFF_DURATION2 = 1000; //in milliseconds
long unsigned ON_DURATION2 = 1000; //in milliseconds


sstimer WATER_PUMP(PIN_NO1, ON_DURATION, OFF_DURATION); //create instance for water pump
sstimer LIGHTHING(PIN_NO2, ON_DURATION2, OFF_DURATION2);//create instance for lighting

void setup(){
//...  
}


void loop(){
//...
WATER_PUMP.startsstimer();
LIGHTHING.startsstimer();
//..  
}