Datalogging query

Hi,
I have made a Mickey-Mouse data-logger using a standalone '328 ( it's not a logger since it only sends data to
a serial monitor, but I'm not a proud man... ). I have used this device to record stuff from solar panels and so on.

I also have a small home-made anemometer on the roof to record wind-speed. Theres a rotor with 3 cups on it.
Inside the case theres an opto-interrupter and a small perforated disc ( salvaged from a computer mouse ). I
made this set-up before I had tried my hand at programming microprocessors and so the output from the
opto-interruper is 'read' by another home-made circuit. Pulses from the interrupter trigger a 555 monoflop.
The O/P from the 555 drives a moving-coil meter movement. The inertia of the meter integrates the 555 pulses.
Yes, it's crude, but I'm not Bob Widlar.

Now I want to upgrade the anemometer and record the wind-speed on the pc. I cant use the datalogger as it is,
since all it does is read a voltage between 0 and 5V. So, how is it done?

Micros have a comparator ( well, some do ) which would convert the pulses from the opto interrupter into a proper
square wave. But then what? The maximum frequency from the opto wouldnt be much more than 1KHz. Somehow,
I would need to start, count the pulses in 1 sec, say, and the send that figure to the serial monitor. Well, that's my
guess, but I'd like others to give me some useful advice,

Regards
Bruce

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.