Measure Flywheel Speed With Encoder Code

Hey guys,
Is it possible to have a shaft encoder to measure the speed of the flywheel and when it’s up to speed make an LED go On?
If so please can you leave some code for me?
Thanks