Intermediate
30 min

Sync your LEDs easily with BD18337EFV-M and ATmega328P

See the light, not the complexity!

LED Driver 14 Click with Arduino UNO Rev3

Published Feb 14, 2024

Click board™

LED Driver 14 Click

Dev Board

Arduino UNO Rev3

Compiler

NECTO Studio

MCU

ATmega328P

With our LED driver solution, controlling multiple LEDs becomes as easy as flicking a switch, giving you the power to create captivating lighting environments effortlessly

A

A

Hardware Overview

How does it work?

LED Driver 14 Click is based on the BD18337EFV-M, a four-channel constant current LED driver with built-in MOSFET ideal for LED rear lamps (turn/stop), fog lamps, and turn signals for automotive use from Rohm Semiconductor. The BD18337EFV-M incorporates a proprietary thermal dissipation circuit, and individual LED control function to drive LED lamps with different specifications by one driver. This allows up to 3 LEDs in series on its output OUTx pin. It also has integrated protection circuitry to guard against output-short, overvoltage, LED short-circuit protections, and overtemperature. This Click board™ provides an output current of 150mA per channel with an output current accuracy of ±5%, limited by two MCP4661 digital potentiometers from Microchip Technology, which establishes communication with the MCU via I2C serial interface. The MCP4661 also allows the choice of the least significant bit (LSB) of its I2C slave address by positioning SMD jumpers labeled as ADDR SEL to an appropriate position marked as 1 and 0. The MCP4661 also has a configurable Write Protection function labeled as WP routed on the

RST pin of the mikroBUS™ socket, which protects the entire memory and all registers from write operations and must be set to a low logic state to inhibit all the write operations. The BD18337EFV-M offers two ways to implement LED dimming: analog and PWM. Both methods control the average current flowing through the LEDs. The analog dimming can be achieved by adjusting the LED current by using an external voltage source on the VIN terminal, while the PWM dimming is implemented by direct control of the dimming control signal routed to the PWM pin on the mikroBUS™ socket. The selection can be made by positioning the SMD jumper labeled CRT SEL to an appropriate position marked as PWM or VIN. This board also has a two-channel switch labeled MSET, which allows changing output channel operation mode based on detecting an LED error. It also uses the INT pin of the mikroBUS™ socket in two ways: a 'fault' indicator, which immediately notifies the host when a fault condition occurs, or as an input that turns off the output current. The output channel operation mode is automatically selected according to a switch position. More information

about these selectable modes can be found in the attached datasheet. This Click board™ supports an external power supply for the motor, which can be connected to the input terminal labeled as VIN and should be within the range of 5.5V to 20V (typically about 12V). This wide range can lead to significant device power consumption in applications where a high input voltage is applied to the device and the output is relatively low. This amount of power can increase the BD18337EFV-M internal temperature to an unacceptable level, depending on the package's thermal resistance. The BD18337EFV-M employs an Energy Sharing Control to solve this issue, dissipating the extra power that can overheat the device in external resistors R2 and R3 (R3 is unpopulated by default configuration). This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.

LED Driver 14 Click hardware overview image

Features overview

Development board

Arduino UNO is a versatile microcontroller board built around the ATmega328P chip. It offers extensive connectivity options for various projects, featuring 14 digital input/output pins, six of which are PWM-capable, along with six analog inputs. Its core components include a 16MHz ceramic resonator, a USB connection, a power jack, an

ICSP header, and a reset button, providing everything necessary to power and program the board. The Uno is ready to go, whether connected to a computer via USB or powered by an AC-to-DC adapter or battery. As the first USB Arduino board, it serves as the benchmark for the Arduino platform, with "Uno" symbolizing its status as the

first in a series. This name choice, meaning "one" in Italian, commemorates the launch of Arduino Software (IDE) 1.0. Initially introduced alongside version 1.0 of the Arduino Software (IDE), the Uno has since become the foundational model for subsequent Arduino releases, embodying the platform's evolution.

Arduino UNO Rev3 double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

AVR

MCU Memory (KB)

32

Silicon Vendor

Microchip

Pin count

28

RAM (Bytes)

2048

You complete me!

Accessories

Click Shield for Arduino UNO has two proprietary mikroBUS™ sockets, allowing all the Click board™ devices to be interfaced with the Arduino UNO board without effort. The Arduino Uno, a microcontroller board based on the ATmega328P, provides an affordable and flexible way for users to try out new concepts and build prototypes with the ATmega328P microcontroller from various combinations of performance, power consumption, and features. The Arduino Uno has 14 digital input/output pins (of which six can be used as PWM outputs), six analog inputs, a 16 MHz ceramic resonator (CSTCE16M0V53-R0), a USB connection, a power jack, an ICSP header, and reset button. Most of the ATmega328P microcontroller pins are brought to the IO pins on the left and right edge of the board, which are then connected to two existing mikroBUS™ sockets. This Click Shield also has several switches that perform functions such as selecting the logic levels of analog signals on mikroBUS™ sockets and selecting logic voltage levels of the mikroBUS™ sockets themselves. Besides, the user is offered the possibility of using any Click board™ with the help of existing bidirectional level-shifting voltage translators, regardless of whether the Click board™ operates at a 3.3V or 5V logic voltage level. Once you connect the Arduino UNO board with our Click Shield for Arduino UNO, you can access hundreds of Click boards™, working with 3.3V or 5V logic voltage levels.

Click Shield for Arduino UNO accessories 1 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
DIGIPOT Write Protect
PD2
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
PWM Signal
PD6
PWM
Interrupt
PC3
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PC5
SCL
I2C Data
PC4
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

LED Driver 14 Click Schematic schematic

Step by step

Project assembly

Click Shield for Arduino UNO front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Arduino UNO Rev3 as your development board.

Click Shield for Arduino UNO front image hardware assembly
Arduino UNO Rev3 front image hardware assembly
Charger 27 Click front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Arduino UNO Rev3 Access MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Arduino UNO MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.

Software Support

Library Description

This library contains API for LED Driver 14 Click driver.

Key functions:

  • leddriver14_set_rset - This function sets the resistance of the selected rset channel

  • leddriver14_get_int_pin - This function returns the int pin logic state

  • leddriver14_set_duty_cycle - This function sets the PWM duty cycle in percentages ( Range[ 0..1 ] )

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * @file main.c
 * @brief LEDDriver14 Click example
 *
 * # Description
 * This example demonstrates the use of LED Driver 14 click board by controlling
 * the brightness of LEDs by changing the PWM Duty Cycle.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration.
 *
 * ## Application Task
 * Adjusts the LEDs' brightness by changing the PWM duty cycle every 500ms.
 * A duty cycle value is being displayed on the USB UART.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "leddriver14.h"

static leddriver14_t leddriver14;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    leddriver14_cfg_t leddriver14_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    leddriver14_cfg_setup( &leddriver14_cfg );
    LEDDRIVER14_MAP_MIKROBUS( leddriver14_cfg, MIKROBUS_1 );
    err_t init_flag = leddriver14_init( &leddriver14, &leddriver14_cfg );
    if ( ( I2C_MASTER_ERROR == init_flag ) || ( PWM_ERROR == init_flag ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( LEDDRIVER14_ERROR == leddriver14_default_cfg ( &leddriver14 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    static int8_t duty_cnt = 1;
    static int8_t duty_inc = 1;
    float duty = duty_cnt / 10.0;
    
    leddriver14_set_duty_cycle ( &leddriver14, duty );
    log_printf( &logger, "> Duty: %d%%\r\n", ( uint16_t )( duty_cnt * 10 ) );
    
    if ( 10 == duty_cnt ) 
    {
        duty_inc = -1;
    }
    else if ( 0 == duty_cnt ) 
    {
        duty_inc = 1;
    }
    duty_cnt += duty_inc;
    
    if ( !leddriver14_get_int_pin ( &leddriver14 ) )
    {
        log_info ( &logger, " Abnormality such as LED Open or the OUTx pin short circuit occured " );
    }
    
    Delay_ms( 500 );
}

void main ( void ) 
{
    application_init( );

    for ( ; ; ) 
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.