pulse counteri

i would realize a pulse counter that has to count a determinate number of pulses in a range time of 30 seconds . I have to on/off a led in accomplish with the countered pulses too. Sorry for my english I'm italian XD

code:
int cont = 0;
int val = 0;
int anag = 4;
int pulse = 0;
int testo = 3;
int led =5;
int tasto=0;
void setup () {
pinMode ( testo, INPUT);
pinMode ( anag, INPUT);
pinMode ( led, OUTPUT);
}
void loop () {
pulse= digitalRead (anag);
tasto= digitalRead (testo);
if (tasto == HIGH ){

val= millis ();
while (millis () - val < 30000 ) {
if ( pulse == HIGH ); {
cont ++;

}
}}
for ( int i=0; i < cont ; i++) {
digitalWrite ( led,LOW );
delay (500);
digitalWrite ( led,HIGH);
delay (500);
}}

what i have to change?
Thank you,

 if ( pulse == HIGH );

Oops.

yes I wrong it, but is the other part of program right?

Why you are askin me this?

I don't know how milliseconds passed. The program have to count 30 second and while he do it also it counts the pulses too. After that 30 seconds he have to do an other action.

i think after 30 seconds or a bit more

OK, I just found the two other copies of this post.
I've deleted them, and I'm out.

you don't have an idea on how to do this program?

what i have to change?

   void loop () {
    pulse= digitalRead (anag);
    tasto= digitalRead (testo);
      if (tasto == HIGH ){

        val= millis ();
        while (millis () - val < 30000 ) {
          if ( pulse == HIGH ); {
          cont ++;

}
}}
    for ( int i=0; i < cont ; i++) {
      digitalWrite ( led,LOW );
      delay (500);
      digitalWrite ( led,HIGH);
      delay (500);
}}

A lot. First, put every { on a new line. Second, put every } on a new line Close curly braces NEVER get doubled up one line.

Third, delete the useless blank lines, and use Tools +Auto Format. Then, your loop function will like this:

void loop ()
{
  pulse= digitalRead (anag);
  tasto= digitalRead (testo);
  if (tasto == HIGH )
  {
    val= millis ();
    while (millis () - val < 30000 ) 
    {
      if ( pulse == HIGH ); 
      {
        cont ++;
      }
    }
  }
  
  for ( int i=0; i < cont ; i++) 
  {
    digitalWrite ( led,LOW );
    delay (500);
    digitalWrite ( led,HIGH);
    delay (500);
  }
}

Now, look at that while loop. It will loop for 30 seconds. During that time, it will test whether pulse is HIGH. If it is, it will do nothing (;). Otherwise, it will do nothing. Then, it will increment cont.

Even if you remove the incorrectly placed ;, the code is still wrong. What causes pulse to change in the while loop? Nothing. So, if pulse is HIGH at the start, you will count as fast as you can, for 30 seconds. If it is LOW to start with, you will do nothing for 30 seconds.

You need to read a value for pulse in the while loop.

But, you do NOT want to be counting pulses if the pin IS HIGH. You want to increment the counter once when the pin BECOMES HIGH. Look at the state change detection example to see how that is done.