In this project we are going to use a Rotary Encoder KY-040 to control a Step Motor and Display a Graphic Gauge.
Raspberry Pi is loaded with Raspbian OS. tkinter Library is included in new Raspbian OS.
A Graphic Rotary Gauge is provided as rotarylib.py.
Rotary Encoder is connected to Raspberry Pi GPIO18 and GPIO23.
these two GPIO are setup as input and binded to Rising and Falling edge event _callbackA.
Base on Rotary Encoder Timing in _callbackA Function we Step_it(1) or Step_it(-1) clockwise or counter clockwise .
in Step_it Function we select one setting for GPIO26, GPIO19, GPIO13 and GPIO6 connected to ULN2003 Inputs.
ULN2003 outputs drive the Step Motor inputs.
- On Raspberry Pi Create a directory
- download Test_RotaryEncoder and unzip it in that folder
- you will see two files rotarylib.py and Test_RotaryEncoder
- On Raspberry Pi under Menu Programming select Thonny Python IDE
- from menu file open file Test_RotaryEncoder.py
- Connect Rotary Encoder,ULN Driver board, Step Motor and 5V /12V Power supply to Raspberry Pi
- run the Python file