Go Down

Topic: READING CODE SIMULTANEOUSLY? (Read 957 times) previous topic - next topic

PEkman

Hi
I am a beginner in this subjekt :D
Is it possible to run two parts of the code at the same time?
ex.
void setup()
{
 pinMode(13, OUTPUT);
 pinMode(12, OUTPUT);
}
 void loop()
 {
 digitalWrite(13, HIGH);
 delay(1000);
 digitalWrite(13, LOW);
 delay(1000);
 }
 void loop ()
 {
 digitalWrite(12, HIGH);
 delay(2000);
 digitalWrite(12, LOW);
 delay(2000);
 }

I know that I cant use void loop twice, but is it possible in some other way?
I hope you understand me  :P

grateful for answers

PaulS

If you want two LEDs to turn on at the same time, and off at the same time, do that.
Code: [Select]
void loop ()
{
 digitalWrite(12, HIGH);
 digitalWrite(13, HIGH);
 delay(2000);
 digitalWrite(12, LOW);
 digitalWrite(13, LOW);
 delay(2000);
}

PEkman

thank you for reply

but if I want one of the LED blink with 1 sec and the other with 2 sec but start at the same time. Is it possible?

AlphaBeta

http://www.arduino.cc/playground/Code/TimedAction

Take a look at the 'The examples at once' which 'reads' three arduino examples at once.

PEkman

thanks!
Thats what Im looking for.
But I have one question, when I copy the code and when I veryfi it it says "TimedAction does not name a type" and the row that is highlighted is

TimedAction blinkAction                 =       TimedAction(1000,blink);

what is the problem?

AlphaBeta

Did you download the library? Refer to the download section.

Did you #include <TimedAction.h>  ?

PEkman

oh...sorry, missed it
starting to get late, my bad

AlphaBeta


Go Up