MATLAB Examples

setLeds

Set individual colours of all the 16 LEDs on Engduino

Contents

Syntax

e.setLeds(vals);

Description

e.setLeds(vals[1-16]) Set individual colours of all the 16 LEDs on Engduino
int e.setLeds(vals[1-16]) Set individual colours of all the 16 LEDs on Engduino with return status

Examples

  • Set individual colours of all the 16 LEDs on Engduino using the Colour properties
  • Connect to Engduino on port 3 and set individual colours of all the 16 LEDs on Engduino using Colour properties

    % Colours are defined in engduino object as:
    %     COLOR_RED =     0
    %     COLOR_GREEN =   1
    %     COLOR_BLUE =    2
    %     COLOR_YELLOW =  3
    %     COLOR_MAGENTA = 4
    %     COLOR_CYA =     5
    %     COLOR_WHITE =   6
    %     COLOR_OFF =     7
    
    % Check if the Engduino object already exists. Otherwise initialize it.
    if (~exist('e', 'var'))
            e = engduino();
    end
    e.setLeds([e.COLOR_RED, e.COLOR_GREEN, e.COLOR_BLUE, e.COLOR_YELLOW, ...
               e.COLOR_MAGENTA, e.COLOR_CYA, e.COLOR_WHITE, e.COLOR_OFF, ...
               e.COLOR_RED, e.COLOR_GREEN, e.COLOR_BLUE, e.COLOR_YELLOW, ...
               e.COLOR_MAGENTA, e.COLOR_CYA, e.COLOR_WHITE, e.COLOR_OFF]);
    

  • Get return status of whether the setLeds() command has been executed successfully
  • Connect to Engduino on port 3 and set individual colours of all the 16 LEDs on Engduino using integers [0-7], return the status code generated by executing the command.

    % Check if the Engduino object already exists. Otherwise initialize it.
    if (~exist('e', 'var'))
            e = engduino();
    end
    res = e.setLeds([1, 2, 3, 4, ...
                     5, 0, 1, 2, ...
                     6, 7, 2, 3, ...
                     1, 2, 3, 4]);
    

    Input Arguments

    vals[1-16] A 1x16 Matrix [color1,...,color16] with colour values correspond to the Engduino LEDs

    Output Arguments

    res Return status to indicate whether function has been executed (int) 0: OK, <0: Error code

    Properties