Komplete Rookie Needs Help - trying to use multiple SetUps / VoidLoops

Hello fellow Arduino-Friends.

First of all hello to everybody:) I am brand new here
and this is my first post.

So far I am a few steps further than the blinking-LED :slight_smile:
And now I have a nice little project going that really grows
with my understanding of the arduino board as well as electronics
in general but still there is a long way to go.

Since using the Arduino the last few days I am amazed how quickly
one can get useful results by puzzling some code elements together
while developing some understanding and try to figure out how everything works.

Also the forum here is a breeze. ALways when I was on the verge of
posting a question I kept working on it and read a few threads more
and mostly got everything going really good.

But now I am a little confused about set-ups & voidLoops and I can’t hold
my question back no more:)

So here it goes:

I got to different things going on but the are run by the arduino
in serial. I try to give out cv in parallel so that the processes
don’t get in the way of each other

So now to give a basic example that simplifies the most of what
I am trying to achieve at this point:

// I’ve got this little example piece of code
// That turns two LEDs on and off respectively

int LED1 = 12;
int LED2 = 11;

void setup() {

  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);

void loop() {

  digitalWrite(LED1, HIGH); 
  digitalWrite(LED2, HIGH);


  digitalWrite(LED1, LOW);
  digitalWrite(LED2, LOW); 

Now I want them to process in parallel not serial
Stupidly explained I want to add more independent loops:

SetUp 1 -> pinMode LED1
Void Loop 1 -> digiHIGH (delay500) digiLOW (delay200)

SetUp 2 -> pinMode LED2
Void Loop 2 -> digiHIGH (delay50) digiLOW (delay40)

// In my research I've found this example from an old threat:

void setup()
void loop()

// Together with the information: 
// "if you have three bits of ... don't throw them all together"
// "join them slowly one at a time."
// "You will need to initialize all your global variables"
// Thanks for contribution:)

I think I am on the right track here but quite honestly I don’t know
how to implememt it.
I've tried to apply it onto my code but can't quite figure out
how to properly do that. I am a real noob with this.

I’ve tried with this:

My general understanding of the Arduino code is
really at beginne-level.

So I think you have to name the setups/voids specifically and then
use them.

Maybe I am just to blind and it’s more easy then I thought.

Hope somebody can help me with this:)

Thanks a bunch and a great weekend to all!!


This nice gentleman came up with sort of block diagram of (electronic) computer way before it became
so popular.

Some of these diagrams have included a block called " program counter". Its primary function is to keep track which line of code is currently used /being executed by CPU.

This "program counter " somewhat follows Newton's First Law - is can be advanced in SINGLE steps unless instructed to "go to" another " code location / count"

In an essence SINGE CPU / computer can execute only ONE instruction at a time - hence in serial fashion.
Parallel computing as you envision it requires more hardware / CPU and very different tools for software development.

There are few "SoC" - systems on the chip - which include multiple CPUs - 4 or even 8 , so "parallel processing " is not just a pipe dream.

Best of luck

Have a look at Planning and Implementing a Program. It uses lots of functions so it may answer your questions.


you are on the right track but calling 'external' loops works only if they do not block execution with delay or some while loop waiting for input.

so first see the BlinkWithoutDelay example.

and here you can see the code separation with more setups and loops in a big style