Using double loop() in same program

Hello There, I am a new in arduino world I don't know why my codes don't work, I wont to try this codes:

int led = 13;
int led2 = 12;

void setup()
{
    pinMode(led, OUTPUT);
    pinMode(led2, OUTPUT);
}
void loop()
{
  digitalWrite(led, HIGH);
  delay(1000);
  digitalWrite(led, LOW);
  delay(1000);
}
void loop()
{
  digitalWrite(led2, HIGH);
  delay(1000);
  digitalWrite(led2, LOW);
  delay(1000);
}

Please help me

I think you want to do duel processing on the Arduino and have two things run at once. The Aruino can't do that. Everything in your code has to be sequential.

You can't redefine the function 'loop' like that. It has already been defined. You will have to figure out what you want to do within the first 'loop' function and that function only. Whether that means calling other functions or just doing everything there for now.

You can only have one function with a given name.

You cannot have two loop() functions, everything you need to do in loop must be in the single loop() function (or function calls made from loop).

Have a look at the demo several things at a time. That is the nearest you will get to multi-processing on an Arduino - and it is pretty convincing.

The trick is to break your actions into small steps and do one step of each action very quickly.

...R

Thank You a lot of you guys, But I need to simple and basic multi processing codes. Can I just remove void loop(), and use only while loop codes, can that possible?

Can I just remove void loop(), and use only while loop codes, can that possible?

No. Did you look at the link that Robin posted ?

The principle used to to check each time through loop() whether it is time to do something or one of several things.