In this blog post I will show you how to use the Rotary B Click from MikroElektronika on an Arduino Uno board. There are several Rotary Click boards available, the only difference being the color of the LEDs. Obviously, the tutorial applies to any of these click boards.
The Rotary click boards can be seen as a 2-in-1 board, combining one EC12D rotary encoder and a set of 16 LEDs, driven by a pair of 74HC595 shift registers. The board can be configured both for 3.3V operation (factory default) and for 5V operation (as in Arduino Uno) by changing the position of an SMD shunt. Besides the change in the operation voltage, another small modification of the click board must be done before using in an Arduino environment.
When the push button on the encoder is pressed we will find Vcc on pin SW. This pin corresponds in its turn to the INT pin on the click socket. And here we come into trouble: there’s no pull down on this pin, so when the button is free the SW pin is floating. The only way to make the push button to work is to install a pull-down resistor. Then button presses can be detected using interrupts.
For the pull-down I have chosen one 10kΩ SMD resistor, in 2012 package (imperial 0805). The size of this resistor is 1.2 x 2 mm, and I can install it on the back of the Rotary Click board, between the push button pin and the existing free pad on the ground plane, as in the pictures below.
Note that in the original code examples for the EasyPIC v7 or Easy AVR v7 boards, the pull-down is activated via the switches on the development board. The code examples provided by MikroElektronika tell exactly which pin we should pull-down: RB0 on the EasyPIC Pro v7 and PD2 on the EasyAVR v7. On the Arduino Uno there are no such switches, so the only way is to install the pull-down resistor like I did. Once the pull-down resistor is installed, the Rotary click board will work with any board with a click socket.
With the above two modifications the click board is ready to be used with the Arduino Uno. In this tutorial I used one Arduino Uno click shield, and I have placed the Rotary B Click in socket #1.