user26371: For a school assignment I need to make a LED blink on/of 3 times then stop. 
Now I have come up with the following code:

I think it's ''clean'' enough for what it has to do, but I have a feeling that here must be a easier way to make the LED blink 3 times. 
Question is: Is there a way to reapeat the part of code 3 times without copy&pasting it?

user11978: Here you can use a loop. a classic for loop in C++ looks like this 
for (int i = 0; i < n; i++)
{
    // content in between these brackets
}

where n is the amount of times you want to loop
you can also instantiate the i before the loop.
int i;
for (i = 0; i < n; i++)
{
    //content here
}

The code below should work. Toy around with it and see what you get.
int ledPin = 13;
int delayPeriod = 500;


void setup(){
    pinMode(ledPin, OUTPUT);

    for (int i = 0; i < 3; i++){
        digitalWrite(ledPin, HIGH);
        delay(delayPeriod);
        digitalWrite(ledPin, LOW);
        delay(delayPeriod);
    }

another approach you can do is using a while loop. These kinds of loops will loop until a given parameter has been met. In your case you want an LED to stop blinking after 3 times. 
int start = 0;
int stop = 3;

while (start <= stop){
    //content here
}

While loops will continue to go as long as the parameter is true. This means something like while(1) will continue to run forever.

26371: <p>For a school assignment I need to make a LED blink on/of 3 times then stop. 
Now I have come up with the following code:</p>

<p><a href="https://i.stack.imgur.com/CVi5O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CVi5O.png" alt="Repeat!"></a></p>

<p>I think it's ''clean'' enough for what it has to do, but I have a feeling that here must be a easier way to make the LED blink 3 times. </p>

<p><strong>Question is: Is there a way to reapeat the part of code 3 times without copy&amp;pasting it?</strong></p>
 11978: <p>Here you can use a loop. a classic for loop in C++ looks like this </p>

<pre><code>for (int i = 0; i &lt; n; i++)
{
    // content in between these brackets
}
</code></pre>

<p>where n is the amount of times you want to loop</p>

<p>you can also instantiate the <code>i</code> before the loop.</p>

<pre><code>int i;
for (i = 0; i &lt; n; i++)
{
    //content here
}
</code></pre>

<p>The code below should work. Toy around with it and see what you get.</p>

<pre><code>int ledPin = 13;
int delayPeriod = 500;


void setup(){
    pinMode(ledPin, OUTPUT);

    for (int i = 0; i &lt; 3; i++){
        digitalWrite(ledPin, HIGH);
        delay(delayPeriod);
        digitalWrite(ledPin, LOW);
        delay(delayPeriod);
    }
</code></pre>

<p>another approach you can do is using a while loop. These kinds of loops will loop until a given parameter has been met. In your case you want an LED to stop blinking after 3 times. </p>

<pre><code>int start = 0;
int stop = 3;

while (start &lt;= stop){
    //content here
}
</code></pre>

<p>While loops will continue to go as long as the parameter is true. This means something like <code>while(1)</code> will continue to run forever.</p>
