leddriver18 2.1.0.0
Main Page

LED Driver 18 click

‍LED Driver 18 Click is a compact add-on board that simplifies the control of multiple LEDs. This board features the TLC5947, a 24-channel LED driver from Texas Instruments. Each channel is individually adjustable with 4096 pulse-width modulated (PWM) steps and has a programmable current value of all channels with a maximum of 30mA of LED current per channel.

click Product page


Click library

  • Author : Stefan Ilic
  • Date : Jan 2023.
  • Type : I2C type

Software Support

We provide a library for the LED Driver 18 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 LED Driver 18 Click driver.

Standard key functions :

Example key functions :

Example Description

‍This library contains API for LED Driver 18 Click driver.

The library initializes and defines the I2C bus drivers to write and read data for setting constant current output, as well as the default configuration for a PWM output value of the OUT pins.

The demo application is composed of two sections :

Application Init

‍Initializes the driver and performs default configuration and sets

the device in output enabled mode.

void application_init ( void )
{
log_cfg_t log_cfg;
leddriver18_cfg_t leddriver18_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
leddriver18_cfg_setup( &leddriver18_cfg );
LEDDRIVER18_MAP_MIKROBUS( leddriver18_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == leddriver18_init( &leddriver18, &leddriver18_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( LEDDRIVER18_ERROR == leddriver18_default_cfg ( &leddriver18 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define LEDDRIVER18_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition leddriver18.h:132
@ LEDDRIVER18_ERROR
Definition leddriver18.h:192
void application_init(void)
Definition main.c:35

Application Task

‍This example demonstrates the use of the LED Driver 18 Click board by

changing PWM values for all output from a minimum value to maximum value and back to minimum controlling the brightness of the LEDs in the process.

void application_task ( void )
{
float pwm_val;
for ( int8_t n_cnt = 0; n_cnt <= 100; n_cnt += 10 )
{
for ( uint8_t out_cnt = 0; out_cnt < LEDDRIVER18_MAX_OUTPUT_NUM; out_cnt++ )
{
leddriver18_set_output_pwm( out_cnt, n_cnt );
}
log_printf( &logger, " PWM value: %.2f \r\n", pwm_val );
leddriver18_write_config( &leddriver18 );
Delay_ms ( 200 );
}
for ( int8_t n_cnt = 100; n_cnt >= 10; n_cnt -= 10 )
{
for ( uint8_t out_cnt = 0; out_cnt < LEDDRIVER18_MAX_OUTPUT_NUM; out_cnt++ )
{
leddriver18_set_output_pwm( out_cnt, n_cnt );
}
log_printf( &logger, " PWM value: %.2f \r\n", pwm_val );
leddriver18_write_config( &leddriver18 );
Delay_ms ( 200 );
}
}
#define LEDDRIVER18_MAX_OUTPUT_NUM
Definition leddriver18.h:93
float leddriver18_get_output_pwm(uint8_t out_num)
LED Driver 18 get output channel PWM value function.
void application_task(void)
Definition main.c:71

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.LEDDriver18

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.