美文网首页
手势传感器9960使用

手势传感器9960使用

作者: Mr洋1 | 来源:发表于2020-05-25 22:59 被阅读0次

    1.简介

    APDS-9960
    具有先进的手势检测、接近检测和数字环境光感应功能,是一款采用单个 8 引脚封装的数字 RGB、环境光、近程和手势传感器装置。该装置具有与 I2C 兼容的接口,为红色、绿色、蓝色、透明 (RGBC),近程和手势感测配有红外 LED。RGB 和环境光感测功能可在多种光条件下以及通过多种减振材料包括深色玻璃的情况下,检测出光强度。此外,集成 UV-IR 遮光滤光片可实现精准的环境光和相关色温感测。


    image.png

    2.接线图

    image.png
    image.png

    3.下载文件

    https://codeload.github.com/adafruit/Adafruit_APDS9960/zip/master

    4、放入library中

    image.png

    5、代码

    #include "Adafruit_APDS9960.h"
    Adafruit_APDS9960 apds;
    
    // the setup function runs once when you press reset or power the board
    void setup() {
      Serial.begin(115200);
      
      if(!apds.begin()){
        Serial.println("failed to initialize device! Please check your wiring.");
      }
      else Serial.println("Device initialized!");
    
      //gesture mode will be entered once proximity mode senses something close
      apds.enableProximity(true);
      apds.enableGesture(true);
    }
    
    // the loop function runs over and over again forever
    void loop() {
      //read a gesture from the device
        uint8_t gesture = apds.readGesture();
        if(gesture == APDS9960_DOWN) Serial.println("v");
        if(gesture == APDS9960_UP) Serial.println("^");
        if(gesture == APDS9960_LEFT) Serial.println("<");
        if(gesture == APDS9960_RIGHT) Serial.println(">");
    }
    

    在串口查看:


    image.png

    相关文章

      网友评论

          本文标题:手势传感器9960使用

          本文链接:https://www.haomeiwen.com/subject/owqpahtx.html