Is this work for frequency counter

Could it be that it works, but only for five seconds?

so you are saying is that should be deleted ?

Can you explain what the difference is between what you expect it to do, and what it actually does do is, please? That's the only commonly-agreed definition of "working" that we currently have.
Maybe a reference to your speed sensor?

Why do you read "val"? You don't do anything with it.

by the mean of not working, it cannot show the frequency through the LCD, it is blank. The thing that i would like to do is showing the frequency through the LCD.

the reference to the speed sensor, you mean a data sheet?

and one more question
the AC must be converted, right? if i want to use the ADC in the ATmega168
Does the code i wrote can do the ADC function?