Turn LED on/off via button
2) Motor RPM using encoder sensor module
This Encoder Sensor Module Digital Output can use to check the rate of an electric motor. This module can be used with a microcontroller for motor speed detection, pulse count and position limit. In principle, any rate meter simply measures the rate at which some event occurs. Usually, this is done by counting the events for a given period of time (integration interval) and then simply dividing the number of events by the time to get the rate.
Note I don't have the require wheel (like this one to actually count the RPM. So, I've made a rectange with equal slot instead. The concept remains the same i.e. if you move the thing faster, the rate increases, hence the "RPM" increases.
To interface with the encoder, we can use polling or interrupt. Both are possible. However, the former may have risks of missing signal if the rate is very fast.