apds9960
Connect to APDS9960 sensor on Arduino hardware using I2C bus
Description
The apds9960
object reads gesture, proximity, and measures clear
light and color (RGB) values using the APDS9960 sensor connected to the I2C bus of the
Arduino® hardware. You can read the data from the sensor in MATLAB® using the Object Functions.
Creation
Description
creates a sensor object with default property values.apds9960obj
= apds9960(arduinoobj
)
creates a sensor object with properties using one or more name-value pair
arguments.apds9960obj
= apds9960(arduinoobj
,Name,Value
)
Input Arguments
Properties
Object Functions
readColor | Reads clear light and RGB components through APDS9960 sensor |
readProximity | Read the proximity from APDS9960 sensor |
readGesture | Read gesture through APDS9960 sensor |
Examples
Create Connection to APDS9960 Sensor
Create an arduino
object.
arduinoobj = arduino('COM4', 'Nano33BLE', 'Libraries', 'APDS9960')
arduino with properties: Port: 'COM4' Board: 'Nano33BLE' AvailablePins: {'D0-D13', 'A0-A7'} AvailableDigitalPins: {'D0-D13', 'A0-A7'} AvailablePWMPins: {'D0-D13'} AvailableAnalogPins: {'A0-A3', 'A6-A7'} AvailableI2CBusIDs: [0, 1] AvailableSerialPortIDs: [1] Libraries: {'APDS9960', 'I2C'} Show all properties
Create the sensor object.
apds9960obj = apds9960(arduinoobj)
APDS9960 with properties: I2CAddress: 57 ('0x39') Bus: 1 SCLPin: 'SCL1' SDAPin: 'SDA1' BitRate: 100000 (bits/s) Show all properties
Create Connection to APDS9960 Sensor with Name-Value pair arguments
Create a sensor object with the bus number 1
and bit rate of
400000
.
clear apds9960obj; apds9960obj = apds9960(arduinoobj, 'Bus', 1, 'BitRate', 400000)
APDS9960 with properties: I2CAddress: 57 ('0x39') Bus: 1 SCLPin: 'SCL1' SDAPin: 'SDA1' BitRate: 400000 (bits/s) Show all properties
Change APDS9960 Sensor Configuration
Create a sensor object with the bus number 1
and bit rate of
400000
.
clear apds9960obj; apds9960obj = apds9960(arduinoobj, 'Bus', 1, 'BitRate', 100000)
APDS9960 with properties: I2CAddress: 57 ('0x39') Bus: 1 SCLPin: 'SCL1' SDAPin: 'SDA1' BitRate: 100000 (bits/s) Gesture: [1x1 GestureConfiguration] Proximity: [1x1 ProximityConfiguration] Color: [1x1 ColorConfiguration]
Access the gesture properties.
apds9960obj.Gesture
ans = Gesture Configuration with properties: Gain: 4 LEDCurrent: 100 LEDBoost: 100 PulseCount: 10 PulseWidth: 8
Change the gesture gain value to 1
and display the gesture
properties.
% Sensor configuration % Change Gain settings of Gesture apds9960obj.Gesture.Gain = 1;
% Display Gesture
apds9960obj.Gesture
ans = Gesture Configuration with properties: Gain: 1 LEDCurrent: 50 LEDBoost: 100 PulseCount: 50 PulseWidth: 8