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.
-
Add #include "cy_rgb_led.h"
-
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);
cy_rgb_led_on(CY_RGB_LED_COLOR_YELLOW, CY_RGB_LED_MAX_BRIGHTNESS);
}
for(;;) {
}
- API Reference Guide
- Cypress Semiconductor, an Infineon Technologies Company
- Cypress Semiconductor GitHub
- ModusToolbox
- PSoC 6 Code Examples using ModusToolbox IDE
- PSoC 6 Middleware
- PSoC 6 Resources - KBA223067
© Cypress Semiconductor Corporation, 2019-2021.