We make a lot of different kits, many of them for audio synths. One of them allows you to use a rotary encoder on a breadboard for your projects.
What are rotary encoders?
Rotary encoders, also known as shaft/quadrature encoders, are devices that can convert the motion of a shaft/axle into analog or digital code. For instance, your volume control dial in the car stereo, or oven knobs, are rotary encoders. Simply put, these are used when your project needs to know if a knob has gone in a particular direction, speed, or position.
How does it work? (Ref: http://www.ni.com/white-paper/4763/en)
So on this particular rotary encoder that we’ve provided, there are 3 values you can keep track of. S (for switch, like a momentary switch), A, and B.
"The most common type of incremental encoder uses two output channels (A and B) to sense position. Using two code tracks with sectors positioned 90 degrees out of phase, the two output channels of the quadrature encoder indicate both position and direction of rotation. If A leads B, for example, the disk is rotating in a clockwise direction. If B leads A, then the disk is rotating in a counter-clockwise direction. By monitoring both the number of pulses and the relative phase of signals A and B, you can track both the position and direction of rotation.” With S - you treat this like a momentary switch. When you press it down, it will register one value (either 1 or 0), and when you let go, it will register another value (either 1 or 0)
So I have this kit, what do I need to know?
- The rotary encoder is: PEC11L-4220F-S0015-ND
- The encoder is rated for a MAX of 10mA @ 5v DC
- Datasheet: http://www.bourns.com/PDFs/pec11l.pdf
- It has 30 “clicks” per 360 degree revolution.
- Its actuator has a 6mm diameter flatted end.
- Only one header is actually electrically relevant - the one labeled -, S, B, A, +. The other header is used solely for helping it stay in the breadboard better.
Step 1: To Use It With a Propeller Microcontroller
Example Code (for the Propeller microcontroller):
When the code is run, the serial terminal shows information like the picture as you turn the knob left or right!