readColor
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
Syntax
Description
[
returns the RGB component values of the sensed light along with the timestamp. The object
function normalizes the RGB values using the clear light intensity value. The
colorData
,timestamp
] = readColor(apds9960obj
)Timestamp
argument is optional.
[
returns the RGB component values of the sensed light along with the timestamp depending on
the colorData
,timestamp
] = readColor(apds9960obj
, colorMode
)ColorMode
argument. The Timestamp
argument is
optional. The RGB values are normalised using the clear light intensity value
Examples
Read Color from Sensor
Create an Arduino object.
arduinoobj = arduino('COM4', 'Nano33BLE', 'Libraries', 'APDS9960');
Create the sensor object for the sensor.
apds9960obj = apds9960(arduinoobj)
Read color data from sensor by setting the ColorMode
property to
normalized
.
Note
Sensor readings after 200 ms are accurate while using the
readColor
function.
The function returns the color data as a three-element vector of the RGB components.
[colorData, timestamp] = readColor(apds9960obj, 'normalized')
colorData = 1×3 0.6000 0.4000 0.4000 timestamp = datetime 17-Jun-2021 13:25:27
Read color data from sensor by setting the ColorMode
property to
raw
.
The first member of the vector of the output is the clear light intensity and the subsequent members are the R, G, and B component values.
[colorData, timestamp] = readColor(apds9960obj, 'raw')
colorData = 1×4 uint16 row vector 5 2 2 2 timestamp = datetime 17-Jun-2021 13:25:28
Input Arguments
Output Arguments
Version History
Introduced in R2021b