For measuring motos speed there can Optical interrupter used like H21A1. This is a device where IR LED and photo-transistor is coupled in to plastic housing. The gap between then allows interrupting signal with opaque material and this way switching the output from ON to OFF.
This device can be connected to Microcontrollers ICP pin and this way measuring PWM disk (with hole in it) speed can be measured. Disk has to me fixed to axis of motor. Each time the hole of disk passes the gap, optical interrupter will form a pulse which goes to ICP pin to trigger the timer. If take measuring interval 1s, then counted pulses will be equal to turns in Hz.
Lets take Atmega8 microcontroller which is clocked at 8MHz. For this lets use timer pre-scaler 8, then timer will run at frequency equal 1MHz(period 1μs ). Each time the pulse reaches ICP(Atmega8 – PB0 pin) pin then on falling front of pulse input capture interrupt occur. Interrupt service routine counts the number of timer pulses between two pulses. Number of timer counts define the disk speed (RPM - revolutions per minute).
Controlling numeric LCD isn't so tricky as it may look like. O course you can find numbers of LCD libraries. One of more universal you can find in AVRLIB library for WinAVR AVR GCC compiler. Main disadvantage of such universal libraries that they compile all functions even if you don't want them. This way huge libraries occupy more program memory than you would like to. One way is to write simple routines specified only to your design.
My simple LCD library include only 8 bit mode. Each pin, connected to LCD, can be configured separately. For instance:
Lets have some practice and write simple AVR LCD menu routine. For this we need to write LCD control library. I decided not to use one from AVRLIB. LCD controlling isn't difficult just a few lines of code unless you want to make it more universal.
I want to demonstrate how LCD menu control may look. Of course this isn't the best practice as it uses pretty simple logic, but may do the job.
To make it interesting I am going to have 4 buttons: 2 for menu scrolling up and down and two for changing submenu parameters. As output I am going to use three LED diodes that will light according to parameters selected in menu. Button states are going to be read using timer0 overflow interrupts. Code is written for WinAVR compiler.