output count

Hello all. Here is my code that I am playing with so far it works halfway. At the moment it display via serial the count twice (same number). What I am trying to do is to count the output off Led1. Example : Led blink 10 times while blinking there should be a counter counting till 10
then after 10 count reach. Led stop another output switch 2 led. Counter only counts Led 1 10 times , then switch Led 1 off. Led 2 then on.

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
  Also added LED output counter.
  This example code is in the public domain.
 */

const int led = 13;  // Pin 13 has an LED connected on most Arduino boards
 int blinkCount;
 int ledState;
void setup() {
  pinMode(led, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  
  long blinkCopy;  // holds a copy of the blinkCount
  blinkCopy = blinkCount;
  Serial.print("blinkCount = ");
  Serial.println(blinkCopy);
  delay(500);
  
  
  if (ledState == LOW) {
    ledState = HIGH;
    blinkCount = blinkCount +1;  // increase when LED turns on
  } else {
    ledState = LOW;
  }
  digitalWrite(led, ledState);


}
volatile unsigned long blinkCount;

The volatile keyword tells the compiler that the variable can change values outside the normal flow of control - as in an interrupt handler. You don't have any interrupt handlers; you don't need the volatile keyword.

What I am trying to do is to count the output off Led1. Example : Led blink 10 times while blinking there should be a counter counting till 10

So, a byte would be plenty. Using a variable 4 times that larger is a 75% waste of resources.

  unsigned long blinkCopy;  // holds a copy of the blinkCount
  blinkCopy = blinkCount;

Why do you need to copy the value?

  void blinkLED(void);

Why is there a function prototype embedded in loop()? Where is the function?

Code:
volatile unsigned long blinkCount;
The volatile keyword tells the compiler that the variable can change values outside the normal flow of control - as in an interrupt handler. You don't have any interrupt handlers; you don't need the volatile keyword.

Sorry for that , but I played around with the code and none of it is my work it is stuff I found on the net.

Quote
What I am trying to do is to count the output off Led1. Example : Led blink 10 times while blinking there should be a counter counting till 10
So, a byte would be plenty. Using a variable 4 times that larger is a 75% waste of resources.

Code:
unsigned long blinkCopy; // holds a copy of the blinkCount
blinkCopy = blinkCount;
Why do you need to copy the value?

IS THERE A BETTER WAY TO DO THIS????????????????

Code:
void blinkLED(void);
Why is there a function prototype embedded in loop()? Where is the function?

Tried to fix it is it better now?

Perhaps you should try better explaining what you are trying to do. You mention a second LED in your first post, but nothing in your code suggests there is one. You also talk about only blinking 10 times, but you never check your count value against 10.

Hello to all. Especially the noobs. I found a solution to my problem and is working 100%.
Here is the code. Take note this is very simple with a function.

/*
 
  Led3 on for one second, then off for one second, repeatedly for 10 times.
  Then Led3 off.Led2 will turn on acording to delay time then off. Then will reset counter.Everything repeats over.
  This example code is in the public domain.
 
 */

const int led3 = 13;// Pin 13 has an LED connected on most Arduino boards
const int led2 = 12;
int blinkCount=0;

void setup() {
  
  pinMode(led3, OUTPUT);
  pinMode(led2, OUTPUT);
  Serial.begin(9600);
}

void led2ontime(){
  digitalWrite(led2,HIGH);
  if (digitalRead(led2) == HIGH){digitalWrite(led3,LOW);}
  Serial.write("             led2 on              ");
  delay(5000);
  blinkCount = 0;
  digitalWrite(led2,LOW);
  
  }
  
void loop() {
  digitalWrite(led3,LOW);
  delay(1000);
  digitalWrite (led3,HIGH);
  if (digitalRead(led3) == HIGH){blinkCount++;}
  delay(100);
  Serial.write(" led3 on ");
  delay(50);
  Serial.print(blinkCount);
  if (blinkCount==10){led2ontime();}
  


}