aaaf5050_mc_k12_write
Writes individual colours to a Kingbright AAAF5050-MC-K12 LED strip.
Description
The aaaf5050_mc_k12_write function writes colours to the LEDs of a Kingbright AAAF5050-MC-K12 LED strip. The RGB values of each LED may be set individually.
Prototype
t_int
aaaf5050_mc_k12_write(t_aaaf5050_mc_k12 led_handle, const t_led_color* colors, t_uint num_leds);
    
    Parameters
t_aaaf5050_mc_k12 led_handle
A handle to the LED strip returned by the aaaf5050_mc_k12_open function.
t_led_color * colors
An array of t_led_color structures defining the RGB color of each LED in the LED strip. The number of elements in this array must be greater than or equal to the num_leds parameter. Each t_led_color structure contains the following fields:
| 
                         Data Type  | 
                    
                         Field  | 
                    
                         Description  | 
                
|---|---|---|
| 
                             t_uint8  | 
                        
                             red  | 
                        
                             The red component as an integer between 0 and 255.  | 
                    
| 
                             t_uint8  | 
                        
                             green  | 
                        
                             The green component as an integer between 0 and 255.  | 
                    
| 
                             t_uint8  | 
                        
                             blue  | 
                        
                             The blue component as an integer between 0 and 255.  | 
                    
t_uint num_leds
The number of elements in the colors array. If this number is less than the maximum number of LEDs then only the first num_leds LEDs will be changed.
Return value
            The return value is the number of LEDs written if successful. Otherwise a negative
            error code is returned. Error codes are
            defined in quanser_errors.h. A suitable error message
            may be retrieved using msg_get_error_message.
        
Error codes
QERR_INVALID_ARGUMENT
One of the arguments is invalid.
Requirements
| 
                     Include Files  | 
                
                     Libraries  | 
            
|---|---|
| 
                     quanser_led.h  | 
                
                     quanser_devices.lib;quanser_communications.lib;quanser_runtime.lib;quanser_common.lib  | 
                
Examples
t_aaaf5050_mc_k12 led_strip;
t_error result = 
    aaaf5050_mc_k12_open("spi://localhost:1?memsize=420,word=8,baud=3333333,lsb=off,frame=1", 33, &led_strip);
if (result == 0) {
    static const t_led_color colors[] =
    {
        { 255, 0, 0 },        /* LED #0: red     */
        { 0, 255, 0 },        /* LED #1: green   */
        { 0, 0, 255 },        /* LED #2: blue    */
        { 255, 255, 0 },      /* LED #3: yellow  */
        { 0, 255, 255 },      /* LED #4: cyan    */
        { 255, 0, 255 },      /* LED #5: magenta */
    };
    aaaf5050_mc_k12_write(led_strip, colors, ARRAY_LENGTH(colors));
    ...
    aaaf5050_mc_k12_close(led_strip);
} else {
    TCHAR message[512];
    msg_get_error_message(NULL, result, message, sizeof(message));
    _tprintf(_T("Failed to open LED strip. %s (error %d)\n"), message, -result);
}
        See Also
        
    
Copyright ©2025 Quanser Inc. This page was generated 2025-06-17. "
                Submit feedback to Quanser about this page.
Link to this page.