First steps

So my dad ordered me an andruino kit and it's going to arrive in around two weeks. Before it arrives I want to become familiar with the language, so here's a simple script i made for two LEDs to flash alternaltely like this (0,0,,1,1[repeat]) Here is the code i put together:

int led0 = 12;
int led1 = 11;

void setup() {
  pinMode(led0, OUTPUT);
  pinMode(led1, OUTPUT);
}

void loop() {

digitalWrite(led0, HIGH);
delay(100);
digitalWrite(led0, LOW);
delay(100);
digitalWrite(led0, HIGH);
delay(100);
digitalWrite(led0, LOW);
delay(100);
digitalWrite(led1, HIGH);
delay(100);
digitalWrite(led1, LOW);
delay(100);
digitalWrite(led1, HIGH);
delay(100);
digitalWrite(led1, LOW);
delay(200);
}

Would that work? If yes, then I have another question. Would it be possible to put loops inside the main loop to make the code shorter?

All you need is:-

void loop() {

digitalWrite(led0, HIGH);
delay(100);
digitalWrite(led0, LOW);
delay(100);
}

Because loop continuously gets called, once it is finished it in effect starts again. That is why it is called loop.

Would that work? If yes, then I have another question. Would it be possible to put loops inside the main loop to make the code shorter?

Yes, it would work. Yes, you can add for loops and while loops to the loop() function.

PaulS:

Would that work? If yes, then I have another question. Would it be possible to put loops inside the main loop to make the code shorter?

Yes, it would work. Yes, you can add for loops and while loops to the loop() function.

I tried doing that, but I got really confused. Can I set a number for how many times the loop will repeat before it ends? Can you make two loops inside a loop that execute one after another? When i try to do that I end up with the two loops looping simultaneously, is there a way to pause one loop to give the other one time to complete a given number of loops?

Can I set a number for how many times the loop will repeat before it ends?

You need to be clear whether you are referring to a for loop or the loop() function. The loop() function executes over and over, forever. The for loop iterates as many times as you tell it to:

for(int i=0; i<someCount; i++)
{
}

will execute while i is less than someCount, incrementing i after each execution of the block of statements.

Can you make two loops inside a loop that execute one after another?

You can do almost anything, with the right code.

When i try to do that I end up with the two loops looping simultaneously

Physically impossible.

is there a way to pause one loop to give the other one time to complete a given number of loops?

Yes, and no. Really, it would be a lot easier to look at, answer questions about specific code. Any code, doesn’t really matter. We are interested in seeing you learn to program.

Karolk:
I tried doing that, but I got really confused. Can I set a number for how many times the loop will repeat before it ends?

Here is an example of your code using a couple of for loops.

int led0 = 12;
int led1 = 11;

void setup() {
  pinMode(led0, OUTPUT);
  pinMode(led1, OUTPUT);
}

void loop() {

   For(int i = 0; i < 2; i++)
   {
   digitalWrite(led0, HIGH);
   delay(100);
   digitalWrite(led0, LOW);
   delay(100);
   }

   For(int i = 0; i < 2; i++)
   {
   digitalWrite(led1, HIGH);
   delay(100);
   digitalWrite(led1, LOW);
   delay(100);
   }

  delay(100);
}

And there is more about them here: http://arduino.cc/en/Reference/for