This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Toggle LED using buttons on light_lightness server example

I am using nrf52840 mesh v17.0.2 light_lightness server example.

In the original Light lightness server code, you can control LED1 using J-Link RTT Viewer. By sending the value 1 or 2 you can decrease or increase the brightness respectively.

What I want to achieve is instead of using J-link to send commands to toggle the brightness, I want to be able to use one physical button (button 3) to toggle LED1.

For instance, by pressing button 3 the first time, LED1 will go to maximum brightness. When the button is pressed a second time, LED1 will be turned off.

How do I go about achieving this? Any help would be greatly appreciated!

  • Hi,

    Do you want to toggle the LED on the board using the button on the same board, is this correct?

  • Hi, 

    I suggest you have a look at the light switch server example. Inside the button_event_handler() you can see how it is done, pressing a button to toggle the LED state and trigger the STATUS message to inform client about the state change  You need to include simple_hal.c to your project just like in the light switch example first because the light lightness setup server example does not use the simple_hal module. So you cannot use buttons on the light lightness server by default.

    This might also be helpful.

Related