how to stop led ON after 5 times

hi there, i'm beginner to Arduino,

i need some help to solve my problem.

how to stop led ON after 5 times?

this is my code

void setup() {

pinMode(18, OUTPUT);

}

void loop() {

digitalWrite(18, HIGH); // turn the LED on

delay(1000); // wait for a second

digitalWrite(18, LOW); // turn the LED off

delay(1000); // wait for a second

}

First welcome to the forum. Second before any one mentions it they would like you to use code tags. What is a code tag? At the top of you screen you will see </> This is a code tag. the easiest way to use it is copy your sketch click on the code tag Paste you sketch between the <> symbols. It is that simple.

By the way I do not see a counting routine in your code to count to 5.

Hi,

Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html
then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

What model arduino are you using?

Thanks .. Tom... :slight_smile:

Move it into a for:loop in setup():

byte count ;
void setup() {

  pinMode(18, OUTPUT);

 for (count = 0; count <5; count = count +1){
  
   digitalWrite(18, HIGH);   // turn the LED on 

   delay(1000);              // wait for a second

   digitalWrite(18, LOW);    // turn the LED off 

  delay(1000);              // wait for a second
 }
}

void loop() {
}