c4x4rgb2  2.1.0.0
Main Page

4x4 RGB 2 click

4x4 RGB 2 Click is a compact add-on board that contains a matrix of 16 intelligent RGB LEDs, forming a 4x4 display screen. This board features 16 IN-PC55TBTRGB, 5x5mm RGB LEDs with an integrated IC from Inolux. The LEDs feature an 8-bit color control in 256 steps (256-level greyscale) and a 5-bit brightness control in 32 steps. The intelligent LEDs are cascaded (daisy-chained); thus, every one of them can communicate with the host MCU using the same data lines.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Mar 2023.
  • Type : SPI type

Software Support

We provide a library for the 4x4 RGB 2 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for 4x4 RGB 2 Click driver.

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of 4x4 RGB 2 click board by setting all 16 LEDs to different colors and changing the LEDs color every 500 milliseconds.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the click default configuration which sets the LEDs brightness to level 1 and the color to black (all LEDs off).

void application_init ( void )
{
log_cfg_t log_cfg;
c4x4rgb2_cfg_t c4x4rgb2_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
c4x4rgb2_cfg_setup( &c4x4rgb2_cfg );
C4X4RGB2_MAP_MIKROBUS( c4x4rgb2_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == c4x4rgb2_init( &c4x4rgb2, &c4x4rgb2_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( C4X4RGB2_ERROR == c4x4rgb2_default_cfg ( &c4x4rgb2 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Sets all 16 LEDs to a different colors and changes their color every 500 milliseconds. All data is displayed on the USB UART where you can track their changes.

void application_task ( void )
{
static uint8_t color_num = 0;
for ( uint8_t led_cnt = C4X4RGB2_LED_0; led_cnt <= C4X4RGB2_LED_15; led_cnt++ )
{
c4x4rgb2_set_led_color ( &c4x4rgb2, led_cnt,
color[ ( led_cnt + color_num ) % C4X4RGB2_NUM_COLORS ].rgb );
log_printf( &logger, " LED %u Color: %s - %.6LX\r\n", ( uint16_t ) led_cnt,
color[ ( led_cnt + color_num ) % C4X4RGB2_NUM_COLORS ].name,
color[ ( led_cnt + color_num ) % C4X4RGB2_NUM_COLORS ].rgb );
}
if ( C4X4RGB2_OK == c4x4rgb2_write_led_matrix ( &c4x4rgb2 ) )
{
log_printf( &logger, " Write LED Matrix\r\n\n" );
Delay_ms ( 500 );
}
if ( ++color_num >= C4X4RGB2_NUM_COLORS )
{
color_num = 0;
}
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.4x4RGB2

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


C4X4RGB2_OK
@ C4X4RGB2_OK
Definition: c4x4rgb2.h:226
C4X4RGB2_ERROR
@ C4X4RGB2_ERROR
Definition: c4x4rgb2.h:227
C4X4RGB2_NUM_COLORS
#define C4X4RGB2_NUM_COLORS
Definition: c4x4rgb2.h:128
C4X4RGB2_LED_15
#define C4X4RGB2_LED_15
Definition: c4x4rgb2.h:96
c4x4rgb2_t
4x4 RGB 2 Click context object.
Definition: c4x4rgb2.h:195
application_task
void application_task(void)
Definition: main.c:86
c4x4rgb2_set_led_brightness
void c4x4rgb2_set_led_brightness(c4x4rgb2_t *ctx, uint8_t led_num, uint8_t brightness)
4x4 RGB 2 set led brightness function.
c4x4rgb2_cfg_t
4x4 RGB 2 Click configuration object.
Definition: c4x4rgb2.h:208
C4X4RGB2_LED_0
#define C4X4RGB2_LED_0
4x4 RGB 2 LED selection values.
Definition: c4x4rgb2.h:81
c4x4rgb2_default_cfg
err_t c4x4rgb2_default_cfg(c4x4rgb2_t *ctx)
4x4 RGB 2 default configuration function.
c4x4rgb2_init
err_t c4x4rgb2_init(c4x4rgb2_t *ctx, c4x4rgb2_cfg_t *cfg)
4x4 RGB 2 initialization function.
C4X4RGB2_MAP_MIKROBUS
#define C4X4RGB2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: c4x4rgb2.h:158
c4x4rgb2_set_led_color
void c4x4rgb2_set_led_color(c4x4rgb2_t *ctx, uint8_t led_num, uint32_t rgb)
4x4 RGB 2 set led color function.
c4x4rgb2_cfg_setup
void c4x4rgb2_cfg_setup(c4x4rgb2_cfg_t *cfg)
4x4 RGB 2 configuration object setup function.
application_init
void application_init(void)
Definition: main.c:50
c4x4rgb2_write_led_matrix
err_t c4x4rgb2_write_led_matrix(c4x4rgb2_t *ctx)
4x4 RGB 2 write led matrix function.