Output signal every 22 sec

Hi,

Im using an Arduino Mega 2650 and IDE 1.0.6.

With the sketch bellow every defined output is getting a 5V pulse every 22 second.

If I add a 10 sec delay at the end of my loop I get 32 seconds between these pulses.

Im very new to this kind of programming so my sketch is probably wrong in some way.

Would really appriciate help with this!

NorgipsMaster1_0.ino (11.2 KB)

I see no question in your post. What would you like to achieve?

every defined output is getting a 5V pulse every 22 second.

If I add a 10 sec delay at the end of my loop I get 32 seconds between these pulses.

22 + 10 == 32.

What's the problem?

Edit: BTW, have you noticed that every case is virtually identical? Sorting that out would make you code much shorter.

You have an AWFUL lot of delay()s in your code.

You need to remove ALL of them and use millis() to manage timing as illustrated in several things at a time.

Then you can make different things wait for different times without interfering with each other.

...R

Agh, the times I see this kind of thing.

  if  (buttonState == HIGH)
  {
    digitalWrite(StartSW, HIGH);
  }
  else
  {
    digitalWrite(StartSW, LOW);
  }

Why not just

    digitalWrite(StartSW, buttonState);

Thanks everyone!

I realized my question wasnt really there. Solved this problem on my own.

Thanks everyone for all the hints though! Very much needed for noobs like myself ;) Sketch works way better now.

dravinci: Solved this problem on my own.

Can you explain how for the benefit of other people who come across this Thread.

...R

Robin2: Can you explain how for the benefit of other people who come across this Thread.

...R

Instead of having the loop running over and over again I put every function in its own loop and connected them to a variable.

dravinci: Instead of having the loop running over and over again I put every function in its own loop and connected them to a variable.

Clear as mud :)