Example: Setting LED colors

Asset Tracker Template

tags
Asset Tracker Template

You can control the LED colors through the LED module using zbus messages. The following is an example of how to set different LED patterns:

/* Set yellow blinking pattern */
struct led_msg led_msg = {
    .type = LED_RGB_SET,
    .red = 255,
    .green = 255,
    .blue = 0,
    .duration_on_msec = 250,
    .duration_off_msec = 2000,
    .repetitions = 10,
};

/* Publish the message to led_chan */
int err = zbus_chan_pub(&led_chan, &led_msg, K_SECONDS(1));
if (err) {
    LOG_ERR("zbus_chan_pub, error: %d", err);
    return;
}