Grow Blink Program so the blinking sequence will stop forever after it loops 3X?

oid setup() {
// put your setup code here, to run once:
pinMode (13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly
int i; //declare an integer variable which we use here also
for (i=0; i<3; i++)
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level);
delay(1000); // wait for a second;
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW;
delay(1000); // wait for a second;
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level);
delay(2000); // wait for two seconds;
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW;
delay(1000); // wait for a second;
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level);
delay(3000); // wait for three seconds;
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW;
delay(1000); // wait for a second;
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level);
delay(4000); // wait for four seconds;
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW;
delay(1000); // wait for a second;
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level);
delay(5000); // wait for five seconds;
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW;
delay(5000); // wait for 5 seconds};
flashLight (1,1);
}
void flashLight(int onTime,int offTime) {
}

Aside from the incomplete code, that won't work. The loop() function will get called again, and blink 3 more times. Then repeat over and over.

Of course, you could use a global boolean to decide whether to blink or not, or you could just move that code to setup() and leave loop() empty.

But, why would you?

As @PaulS says the usual way to control the number of times something happens is to use a variable as a counter and increment it in each iteration. When the counter reaches the desired number stop.

And please post your program using the code button </>

so it looks like this

…R

Robin2:
As @PaulS says the usual way to control the number of times something happens is to use a variable as a counter and increment it in each iteration. When the counter reaches the desired number stop.

And please post your program using the code button </>

so it looks like this

…R

Can you please write it out for me in code so it goes through the blinking process and then stops forever after doing it 3 times?

irenes84:
Can you please write it out for me in code so it goes through the blinking process and then stops forever after doing it 3 times?

I thought that was your job ? :slight_smile:

Something like this

void loop() {
   if (flashCount < 3) {
     // make it flash
     flashCount += 1;
   }
}

Have a look at planning and implementing a program.

…R