Input from Rhythm metronome

Hi, I have now built a metronome that controls the tempo and time signature using two potentiometers. This works great in 2/4, 3/4 and 4/4. One thing that lots of modern electronic metronomes have that mine does not, is the ability to use some kind of button input to set the tempo i.e. I press it in time to the music and it sets it to that tempo. I would like to be able to do that with a piezo that you put on a table or something and tap in time to the music. I would like the arduino program to average out the beats and come up with a tempo - and then do it.

I am not asking for anybody to write it for me - but I would like to have a starting step to help me in this. The only inputs that I've used so far are pots and I don't know how to measure a time interval on an analogue input.

Thanks

Have a look here for tap tempo - http://umlautllama.com/projects/arduino/

Or google for arduino tap tempo