When you get an input command, set a variable so you know that the command was received but not yet carried out. When you carry out the first part of the command, change the variable so you know that the first part was done. You would often need to know when it was done, because the next part of the command has to happen 100 milliseconds later.
The demo Several Things at a Time illustrates the use of millis() to manage timing. It may help with understanding the technique. The program style is like what @MorganS recommends.
Thank you all for your help.
For me, because I dont know at all C+ seems very difficult.
I will try to follow MorganS sugestions if I found on web. but an example to set a second to an relay will be more usefull to me.
Nick, I dont realy understand your question. I switch the relays from webpage and when I press many of them without wait my arduino will freeze and after 1 min will "unlock", but I receive only a part of commands. I mean only half of them will understand the command.
I switch the relays from webpage and when I press many of them without wait my arduino will freeze and after 1 min will "unlock", but I receive only a part of commands. I mean only half of them will understand the command.
You need to show ALL of your code. Each time you do something on the web page, a GET request is made. Each GET request is a completely separate event, from a completely separate client. Each takes time to process.
The Arduino's ethernet shield can only handle 4 concurrent client requests. The Arduino can only process one of them at a time.
That code doesn't seem too large. You could probably have posted it inside [ code ] tags.
First, it seems that you've created your own functions for finding strings and clearing memory. It's much more efficient to use the standard string library. http://en.cppreference.com/w/c/string/byte Even though the library has a huge number of functions, the linker only includes the functions you actually used, so it is usually smaller and faster than writing your own.
Second, it looks like the only function you are doing with the relays is pulsing any relay on for 100 ms. So when you turn a relay on, set a timer. In the main loop, while you're waiting for another client request, check the timer. If it's older than 100ms then turn off all the relays. You don't even need to know which one was turned on - it takes a microsecond to turn them all off.
robertaccess:
Nick, I dont realy understand your question. I switch the relays from webpage and when I press many of them without wait my arduino will freeze
What sort of relays are they exactly? (link)
Are you using transistors or similar to operate the relay?