How can I introduce " 2 " loops in one sketch , since " 2 " different delays are the prime factor, and loop() 1 and loop() 2 , has to work simultaneous , not 1 before other, thanks
You don't you get rid of the delays - see blink without delay.
Blink without delay ?, how exactly do you mean ?, how this solve my problem ?.
Time everything using millis() instead of using delay() which blocks the sketch. Blocking means that nothing else can happen. Timing means starting something, noting the time and then checking whether it is time to start something else or stop something. The blink without delay example shows this approach. Once you get the hang of it, it's easy.
It refers to an example program in the IDE.
The technique that it uses involves noting a start time then checking periodically to see whether a time interval has passed. If yes then react to it, if not the go and do something else such as checking whether another timing period has elapsed.
Unlike using the delay() function the program does not stall whilst the delay happens, so that the Arduino can appear to do 2 (or more) things at the same time.
You can load and run the Blink Without Delay sketch by following the Arduino IDE menu sequence
File --> Examples --> Digital --> BlinkWithoutDelay
has to work simultaneous , not 1 before other, thanks
First concept to understand for a arduino AVR microprocessor is that it is a single 'core' processor and can only execute code one step one at a time, there in no 'simultaneous' capability. However the speed of execution can be such that many functions can execute 'independently' from other functions in your sketch as long as there are no 'blocking functions' being used, and delay is one example of a blocking function. Usings the millis() function is one way to setup time interval testing such that one's sketch can determine if enough time as passed or not for any given user function and just skip it if not or process the function if it has. Blink with delay is just one simple example of how one can structure one's code to avoid a blocking function like delay().
Thanks guys, I think am getting enlightening to " brink without delay " ,I will class myself a bit before continuing my project.
You might want to try this:- http://www.thebox.myzen.co.uk/Tutorial/State_Machine.html Others have told me they find it useful.
ulobab: Thanks guys, I think am getting enlightening to " brink without delay " ,I will class myself a bit before continuing my project.
While you're at it load, read, and try running -all- of the ~/examples. Some you may not have the hardware for, but read them anyway just to see what they do. That's just to 'click' them in you head so that when you have a question about that kind of topc later you'll know to go there first to look for an example/answer.
Thanks guys, this is working for me, I've been able to used about 3 different timers, but is working good, thanks again
ulobab: Thanks guys, this is working for me, I've been able to used about 3 different timers, but is working good, thanks again
OMG! Like will someone promote this Newbie two or three levels please! S/He listened, S/He read, S/He implemented the solution.
Ulobab, you are my hero. You are going on to great things, dude XD