Thanks to the high brightness of the LED elements and their color consistency, this Click board™ can be used in various decorative applications, simple pattern displays, color number displays, and due to a cascade nature of the Click board™ itself, they can even be used for building larger screens and displays.
HOW DOES IT WORK?
4x4 RGB click carries sixteen LED elements labeled as WS2812 - intelligent LED elements with an integrated control, from Worldsemi Corporation, arranged in 4 by 4 matrix. These LED elements are composed of red, green, and blue LED segments, forming an RGB LED cell, with their intensities controlled by the integrated logic section. This integrated control section allows separate 8 bit control of each RGB segment, forming 24bit color palette, allowing 16,777,216 different colors to be displayed.
The integrated logic communicates with the host MCU by a single line. The data transfer protocol uses the non-return-to-zero (NRZ) communication mode, so the timing of the data signal is critical. The logical 1 consists of a signal with a certain HIGH and LOW timing. The logical 0 also consists of a signal with a certain HIGH and LOW timing. The difference between logical 0 and 1 is in the timings of HIGH and LOW signal states, as illustrated in the picture below:
The values of these timings are shown in the following table:
|HIGH level timing for logic 0
|LOW level timing for logic 0
|HIGH level timing for logic 1
|LOW level timing for logic 1
|LOW level timing for RESET
This means that sending logical 1 to the WS2812 device, the host MCU has to keep the data line HIGH for 0.7us then LOW for another 0.6us. Once the first 24bits are completed this way, the RST impulse will latch the data in.
The communication line can be selected with the onboard SW1 switch. It offers selection between the mikroBUS™ RST and CS lines, labeled as IN1 and IN2. The communication voltage level can be set by the onboard SMD jumper, labeled as the IO LEVEL and it can be chosen between 3.3V and 5V, allowing interfacing to both 3.3V and 5V MCUs.
The power supply for the LED elements is provided by the MCP1826, a low-voltage, low quiescent current LDO regulator from Microchip, which can provide current up to 1A. While the logic voltage can be selected between 3.3V and 5V rails, the LED power supply is derrived from the 5V mikroBUS™ power rail. It is reduced to 3.5V by the LDO, and distributed to the LED supply inputs of the WS2812 elements.
The PWM pin of the mikroBUS™, which is labeled as OUT on this Click board™, allows cascading of multiple 4x4 RGB click devices. It simply routes the data line back to the mikroBUS™, allowing it to be re-used for the next 4x4 RGB click, and so on. The length of the whole chain is limited only by the communication speed, required to scan through all the LED devices, in order to maintain a reasonable refresh speed.
More detailed explanation of the data communication can be found in the WS2812 datasheet. However, MikroElektronika provides a library that contains functions compatible with the MikroElektronika compilers, which can be used for simplified programming of the 4x4 RGB click. The library also contains an example application, which demonstrates their use. This example application can be used as a reference for custom designs.
||RGB Matrix display that can be used for many decorative functions, showing different kind of patterns or characters, or for providing a visual feedback
||WS2812 - intelligent LED elements with an integrated control, from Worldsemi Corporation; MCP1826, a low-voltage LDO regulator from Microchip
||High brightness smart LED elements allow display of various patterns in 16,777,216 different colors, data out pin for a cascading additional devices, simplified programming with the included library functions
|Click board size
||L (57.15 x 25.4 mm)
This table shows how the pinout on 4x4 RGB click corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).
|Data input 1
|Data input 2
ONBOARD SETTINGS AND INDICATORS
||Data Input selection jumper: left position IN2, right position IN1
||Voltage Logic Level Selection: left position 3.3V, right position 5V
We provide a library for the 4x4 RGB click on our LibStock page, as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Library performs control of the LED color and light efects. Library uses LED color control to perform some applications, like snake application in different colors and screen light also in different colors. The LED matrix on the 4x4 RGB click is connected to the target board microcontroller through the mikroBUS RST pin.
void RGBLed_ZeroBit() - Determines logic low state for the LED diode.
void RGBLed_OneBit() - Determines logic high state for the LED diode.
void RGBLed_ResetDelay() - Reset function which inludes the determined delay time.
void RGBLed_InitDiode(unsigned long ARGBColor, unsigned long * AdiodeArray) - Makes the array with values to set the desired diodes depending on the desired color.
void RGBLed_SetColor(unsigned long * AdiodeArray) - Uses maked array and functions for setting LED diode to logic low or high state to set LED to the desired color.
void RGBLed_SetDiode(char ANum, unsigned long AColor, unsigned long * AdiodeArray) - Turns the determined LED diode (ANum) to the desired color by using SetColor function.
void RGBLed_InitHW() - Performs the hardware pin initialization.
void Delay_time() - Determines the time delay value.
void FillScreen() - Turns all LED diodes to the desired color.
Code snippet - Turns all LED diodes (fills all screen, LED matrix) to different colors with the delay time of 50 miliseconds.
The full application code, and ready to use projects can be found on our LibStock page.
TempColor = 0x002F2F2F; // White
n=10; // 10*5ms = 50ms delay
TempColor = 0x0000002F; // Blue color
TempColor = 0x00002F2F; // Bright blue color
TempColor = 0x00002F00; // Green colcor
TempColor = 0x002F2F00; // Yellow color back