RGB LED (rgb-led)
RGB LED

Overview

Provides functions for controlling an RGB LED. This library implements color mixing and brightness control using the PWM blocks.

  • The cy_rgb_led_init() function accepts the active logic (high or low) of the RGB LED as a parameter. All three (red, green, and blue) LEDs must be connected in same configuration, either active high or active low.
  • The cy_rgb_led_init() function registers a low power handler that prevents the device from entering low power (deep-sleep) mode when the RGB LED is ON. You need to call cy_rgb_led_off() to turn the LED OFF before entering low power mode.

Quick Start

  1. Add #include "cy_rgb_led.h"
  2. Add the following code to the main() function. This example initializes the RGB LED and produces a yellow color with maximum brightness.

    CYBSP_LED_RGB_RED, CYBSP_LED_RGB_GREEN, and CYBSP_LED_RGB_BLUE are defined in the BSP.

cy_rslt_t result;
result = cybsp_init();
if(result == CY_RSLT_SUCCESS) {
result = cy_rgb_led_init(CYBSP_LED_RGB_RED, CYBSP_LED_RGB_GREEN, CYBSP_LED_RGB_BLUE, CY_RGB_LED_ACTIVE_LOW);
}
for(;;) {
}

More information