readColor
Reads clear light and RGB components through APDS9960 sensor
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. ThecolorData
,timestamp
] = readColor(apds9960obj
)Timestamp
argument is optional.
[
returns the RGB component values of the sensed light along with the timestamp depending on thecolorData
,timestamp
] = readColor(apds9960obj
,colorMode
)ColorMode
论点。的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 theColorMode
property tonormalized
.
Note
Sensor readings after 200 ms are accurate while using thereadColor
function.
的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 theColorMode
property toraw
.
的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