RGB LED with NRF5340

Hi,

I need your help to know "How to control RGB LED using PWM in nrf5340?". I have already tried the "RGB_led" sample in NRFconnect SDK v1.5.0 

But can't able to control my led. Kindly Support me to understand the Project and also to get output.

Thanks & Regards 

Navin Chakravarthy K

  • Hi,

    I am looking into it and will get back to you within a day or two. Also, by controlling the LED, could you be more specific as to how you wish to do so?

    Regards,

    Priyanka

  • 0
    199 pts.
    in reply to PK

    Hi Priyanka,

     I want to use via PWM individual mode of nrf5340 or SDK already has RGB LED samples  I need to know how to use that sample for nrf5340

    Thanks & regards

    Navin

  • 0
    190 pts.
    in reply to Mr.NCK

    Hi Navin,

    Since the nrf5340 has only 4 green LEDS, and does not have dedicated red or blue LEDs, while running the ''rgb_led'' exampleyou will have to consider any two LEDs to be red and blue respectively (for eg: led0 -> green, led1-> blue, led2 -> red) 

    Making any changes in the main.c file may cause errors so it would be better if this change is reflected in the .dts file. For which, you don't have to modify that, but you can create a .overlay file inside the ''rgb_led'' folder. Here, you can mention the changes that you want to see in the .dts file (the LEDs you wish to set). 

    This will help you build and flash the program onto the DK. 

    Also, I would recommend you to use the latest version of nrf Connect.

    Hope this helps Slight smile

    Kind Regards,

    Priyanka

  • 0
    199 pts.
    in reply to PK

    Hi Priyanka,

    Basically, RGB led means multicolor controllable led. For your reference "www.circuitbread.com/.../how-rgb-leds-work-and-how-to-control-color"

    And that can be controlled via PWM. Kindly, Check that link and suggest a way to control multicolor led with nrf5340

    Thanks & Regards

    Navin Chakravarthy K

  • 0
    190 pts.
    in reply to Mr.NCK

    Hi Navin,

    I guess there was a bit of a confusion in what I mentioned yesterday. I get that an RGB Led is a multicolour LED but there is no such LED on nrf5340 DK. It has just 4 green LEDs.

    But if you need to run the 'rgb_led' example with an RGB Led, then you will have to use an external analog RGB Led and also, create a  .overlay file with the necessary pwm leds initialised. You can do it like I mentioned yesterday.

    PK said:
    Making any changes in the main.c file may cause errors so it would be better if this change is reflected in the .dts file. For which, you don't have to modify that, but you can create a .overlay file inside the ''rgb_led'' folder. Here, you can mention the changes that you want to see in the .dts file (the LEDs you wish to set). 

    I will attach my .overlay file for your reference. Also, make sure your RGB led pins are connected to the proper pins and you can calculate the resistance required by using your voltage supply and current limit from the datasheet of the RGB Led.

    As for controlling the LED, you could try making changes in the main.c of the 'rgb_led' example. At present, it runs as per a for loop with a specific count that is defined. You could try changing this. In case you need to control them via buttons, you may have to again define them in the .overlay file.

    5305.nrf5340dk_nrf5340_cpuapp.overlay

    Hope this helps.

    Kind Regards,

    Priyanka

Related