Datalogging query

Basically you would need a counter variable and setup some sort of timer on the microcontroller. Either poll the input pin in the main loop or have an interrupt every it goes high, but in either case the counter value would increment once per pulse from the opto-interrupter. The timer would be set for a constant interval, a second would be fine but a shorter interval like a half or quarter second would work as well. Once the interval is up, the variable is used to do math necessary to figure the windspeed, then reset to zero. The microcontroller can send the results to the computer while waiting for the next interval to elapse. How you save the data on the computer will depend on what program is communicating with the microprocessor.

By the way, it is possible to have the microcontroller record this data directly to a text file on a SD or microSD card in addition to sending it to the computer.