Wheel speed from Shimano dyamo hub using arduino
While the accepted answer works just fine, if you're using an arduino it can actually be slightly simpler.  Atmega chips have clamping diodes on the input pins, meaning that with the right current restrictions the voltage can be well out of range of what would otherwise be tolerated on the input pins.  Essentially you would just run the input signal through a large resistance, as in the following diagram from AVR182:



Using this method, D1, R3, Z1, and C3  from Asmyldof's answer are no longer necessary, but a very small value for C3 may still be helpful for some noise filtering.