Due to high demand expect some shipping delays at this time, orders may not ship for 3-4 business days. On MLK Day no orders will be shipped.
0

APDS-9960 gesture sensor not detecting gestures
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

APDS-9960 gesture sensor not detecting gestures

by licjn on Sat Dec 04, 2021 11:37 pm

I have the APDS-9960 connected via stemma QT to an Arduino Nano 2040 Connect. It is not sensing my gestures and consistently reads a 0 when multi_sensor.gesture( ) is called. The reading does not change when I move my hand in front of it in the right, left, up, down directions. Does anyone have any insight into this?

Below is the code I am running:
Code: Select all | TOGGLE FULL SIZE
# Gesture sensing with APDS9960

import time, board
from audiocore import WaveFile
from adafruit_apds9960.apds9960 import APDS9960

# if using QT Py
# import busio
# i2c = busio.I2C(board.SCL1, board,SDA1)

# create i2c object and use i2c object to create APDS9960 object
i2c = board.I2C()
multi_sensor = APDS9960(i2c)

#turn on proximity sensing
multi_sensor.eneable_proximity = True
multi_sensor.enable_gesture = True

# readings are from the sensor object's .gesture() method
# return as 1, 2, 3, or 4 --> up, down, left, or right respectively

# set up audiobusio
try:
    from audioio import AudioOut
except ImportError:
    try:
        from audiopwmio import PWMAudioOut as AudioOut
    except ImportError:
        print("This board does not support AUdioOut")

# configure audioout and set path
audio = AudioOut(board.D3)
path = "sounds/"

def play_sound(filename):
    with open(path + filename, "rb") as wave_file:
        wave = WaveFile(wave_file)
        audio.play(wave)
        while audio.playing:
            pass

while True:
    gesture = multi_sensor.gesture()
    print(gesture)
    if gesture == 3: # left
        print("left")
        play_sound("not-the-droids.wav")
    if gesture == 4: # right
        print("right")
        play_sound("no-id.wav")
    time.sleep(0.1)

licjn
 
Posts: 3
Joined: Tue Nov 16, 2021 12:53 am

Re: APDS-9960 gesture sensor not detecting gestures

by licjn on Sat Dec 04, 2021 11:59 pm

I was able to read gestures using the Adafruit example code so perhaps it was something wrong with my code above. I hade a minor typo mispelling in my code! that's all.

Code: Select all | TOGGLE FULL SIZE
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import board
from adafruit_apds9960.apds9960 import APDS9960

i2c = board.I2C()

apds = APDS9960(i2c)
apds.enable_proximity = True
apds.enable_gesture = True

# Uncomment and set the rotation if depending on how your sensor is mounted.
# apds.rotation = 270 # 270 for CLUE

while True:
    gesture = apds.gesture()

    if gesture == 0x01:
        print("up")
    elif gesture == 0x02:
        print("down")
    elif gesture == 0x03:
        print("left")
    elif gesture == 0x04:
        print("right")

licjn
 
Posts: 3
Joined: Tue Nov 16, 2021 12:53 am

Please be positive and constructive with your questions and comments.