ኮድ ይፈልጉ

ኤፒዲኤስ-9960 የእጅ ምልክት ዳሳሽ ከአርዱኖ ጋር

ኤፒዲኤስ-9960 የእጅ ምልክት ዳሳሽ ከአርዱኖ ጋር

የAPDS-9960 የእጅ ምልክት ዳሳሽ እንደ መጥረግ እና ቅርበት ያሉ የእጅ ምልክቶችን መለየት ያስችላል። በዚህ መማሪያ ውስጥ፣ APDS-9960ን ከአርዱኖ ጋር እንዴት ማገናኘት እና ምልክቶችን እንዲለይ ፕሮግራም ማድረግ እንደሚቻል እናሳያለን። ውጤቱም እንቅስቃሴዎችን መለየት እና በተከታታይ መቆጣጠሪያ ማሳወቅ የሚችል ቀላል ዝግጅት ይሆናል። ይህ መመሪያ ከእጅ ምልክት ዳሳሽ ጋር ለመጀመር የሚያስፈልጉትን ሽቦዎች እና ኮድ እንዲረዱ ይረዳዎታል። (በቪዲዮ 00:30 ላይ)
APDS-9960 gesture sensor module -1

ሃርድዌር ተብራርቷል

APDS-9960 የRGB ቀለም ዳሳሽ፣ የአካባቢ ብርሃን ዳሳሽ፣ የቅርበት ዳሳሽ እና የእጅ ምልክት መለያ ችሎታዎችን የሚያጣምር ሁለገብ ዳሳሽ ነው። ከአርዱኖ ጋር በI2C ይገናኛል፣ ይህም በትንሽ ሽቦ በቀላሉ ለማዋሃድ ያስችላል። ዳሳሹ የሚሰራው በ3.3V ብቻ ነው፣ ስለዚህ መሳሪያውን ላለማበላሸት ትክክለኛ የቮልቴጅ ደረጃዎችን ማረጋገጥ አስፈላጊ ነው። በዚህ ግንባታ ውስጥ፣ የእጅ ምልክት መረጃን ለማንበብ አርዱኖን እንጠቀማለን። ዳሳሹ የእጅ ምልክት መረጃን በማቋረጫ (interrupts) ያወጣል፣ ይህም አርዱኖ ለእጅ እንቅስቃሴዎች በፍጥነት ምላሽ እንዲሰጥ ያስችላል። APDS-9960ን ከአርዱኖ ጋር ማዋሃድ በእጅ ምልክት የሚቆጣጠሩ መሳሪያዎችን ጨምሮ ለበይነተገናኝ ፕሮጀክቶች ብዙ እድሎችን ይከፍታል።

የዳታሼት ዝርዝሮች

አምራችBroadcom
የክፍል ቁጥርAPDS-9960
የሎጂክ/IO ቮልቴጅ2.7 - 3.6 ቪ
የአቅርቦት ቮልቴጅ3.3 ቪ
የውጤት ጅረት (በአንድ ቻናል)1 ሚኤ
ከፍተኛ ጅረት (በአንድ ቻናል)10 ሚኤ
የPWM ድግግሞሽ መመሪያ100 ኸርዝ
የግቤት ሎጂክ ገደቦች0.3 x VDD (ዝቅተኛ)፣ 0.7 x VDD (ከፍተኛ)
የቮልቴጅ ጠብታ / RDS(on) / ሙሌት0.5 ቪ ከፍተኛ
የሙቀት ገደቦች-40 እስከ +85 °ሴ
ፓኬጅ6-ፒን LGA
ማስታወሻዎች / ልዩነቶችI2C ግንኙነትን ይደግፋል

  • ጉዳትን ለመከላከል የአቅርቦት ቮልቴጅ ከ3.6 ቪ እንዳይበልጥ ያረጋግጡ።
  • አስተማማኝ ግንኙነት ለማግኘት በI2C መስመሮች ላይ የመጎተቻ ተቃዋሚዎችን (pull-up resistors) ይጠቀሙ።
  • ትክክለኛ ንባቦችን ለማግኘት ዳሳሹን ከቀጥታ የፀሐይ ብርሃን ያርቁ።
  • በኮዱ ውስጥ ዳሳሹን በትክክል መጀመርዎን ያረጋግጡ።
  • ተንሳፋፊ ግቤቶችን ለማስቀረት የሽቦ ግንኙነቶችን ይፈትሹ።

የሽቦ መጫኛ መመሪያዎች

Arduino wiring for APDS9960 Gesture sensor
Arduino wiring for APDS9960 Gesture sensor
APDS-9960ን ከአርዱኖ ጋር ለማገናኘት፣ በመጀመሪያ ኃይልን በማገናኘት ይጀምሩ። የAPDS-9960ን የVCC ፒን ከአርዱኖው 3.3V ፒን ጋር ለማገናኘት ቀይ ሽቦ ይጠቀሙ። በመቀጠል፣ የዳሳሹን የGND ፒን በጥቁር ሽቦ በመጠቀም በአርዱኖው ላይ ካለው የመሬት (ground) ፒን ጋር ያገናኙ። አሁን፣ ለI2C ግንኙነት፣ የAPDS-9960ን የSDA ፒን ከአርዱኖው A4 ፒን ጋር ያገናኙ። በተመሳሳይ፣ የSCL ፒንን በአርዱኖው ላይ ካለው A5 ፒን ጋር ያገናኙ። በመጨረሻም፣ የዳሳሹን የINT ፒን በአርዱኖው ላይ ካለው ፒን 2 ጋር ያገናኙ። ይህ አርዱኖ በዳሳሹ የሚፈጠሩትን ማቋረጫዎች ምላሽ እንዲሰጥ ያስችላል።

የኮድ ምሳሌዎች እና ማብራሪያ

የቀረበው ኮድ የAPDS-9960 ዳሳሹን ይጀምራል እና አርዱኖ የእጅ ምልክቶችን እንዲያነብ ያዘጋጃል። የማዋቀር ተግባሩ አጭር ቅንጭብጭብ እነሆ፡-
void setup() {
  pinMode(APDS9960_INT, INPUT);
  Serial.begin(9600);
  attachInterrupt(0, interruptRoutine, FALLING);
  if ( apds.init() ) {
    Serial.println(F("APDS-9960 initialization complete"));
  }
}
በዚህ ቅንጭብጭብ ውስጥ፣ የተከታታይ መቆጣጠሪያውን እንጀምራለን እና የማቋረጫ ፒንን እናዘጋጃለን። ዳሳሹ ይጀመራል፣ እና የማረጋገጫ መልእክት በኮንሶሉ ላይ ይታተማል። በመቀጠል፣ በloop ተግባር ውስጥ የእጅ ምልክቶችን እንፈትሻለን፡-
void loop() {
  if( isr_flag == 1 ) {
    detachInterrupt(0);
    handleGesture();
    isr_flag = 0;
    attachInterrupt(0, interruptRoutine, FALLING);
  }
}
እዚህ፣ loop ያለማቋረጥ የእጅ ምልክቶችን ይፈትሻል። የእጅ ምልክት ሲገኝ፣ ማቋረጫው ይሰናከላል፣ እና ምልክቱን ለማስኬድ `handleGesture` ተግባር ይጠራል። በመጨረሻም፣ `handleGesture` ተግባር የተገኙትን የእጅ ምልክቶች ያስኬዳል፡-
void handleGesture() {
  if ( apds.isGestureAvailable() ) {
    switch ( apds.readGesture() ) {
      case DIR_UP:
        Serial.println("UP");
        break;
      case DIR_DOWN:
        Serial.println("DOWN");
        break;
      // ተጨማሪ ጉዳዮች...
    }
  }
}
በዚህ ተግባር ውስጥ፣ የእጅ ምልክቱ ይነበባል፣ እና በተገኘው አቅጣጫ ላይ በመመስረት ተጓዳኝ እርምጃ ይወሰዳል። ይህ በእጅ እንቅስቃሴዎች ላይ የተመሠረተ በይነተገናኝ ቁጥጥር ያስችላል። ለኮዱ ሙሉ ግንዛቤ፣ ከጽሑፉ በታች የተጫነውን ሙሉ ፕሮግራም ይመልከቱ።

ማሳያ / ምን እንደሚጠበቅ

ዝግጅቱ ሲጠናቀቅ፣ አርዱኖ የእጅ ምልክቶችን እንዲያነብ እና የተገኘውን አቅጣጫ በተከታታይ መቆጣጠሪያ ላይ እንዲያሳይ ይጠበቃል። ቀላል ሙከራዎች እጅዎን ወደ ላይ፣ ወደ ታች፣ ወደ ግራ፣ ወይም ወደ ቀኝ በዳሳሹ ፊት ማንቀሳቀስን ያካትታሉ። ሁሉም ነገር በትክክል ከተገናኘ፣ የእጅ ምልክት መለያውን የሚያረጋግጥ ተጓዳኝ ውጤት በተከታታይ መቆጣጠሪያ ላይ ማየት ይኖርብዎታል። ተንሳፋፊ ግቤቶችን ይጠንቀቁ፣ ምክንያቱም ወጥነት የሌላቸው ንባቦችን ሊያስከትሉ ይችላሉ (በቪዲዮ 05:20 ላይ)።

የቪዲዮ የጊዜ ማህተሞች

  • 00:00 - መግቢያ
  • 01:15 - የሃርድዌር አጠቃላይ እይታ
  • 03:00 - የሽቦ መጫኛ መመሪያዎች
  • 04:30 - የኮድ ማብራሪያ
  • 06:15 - ማሳያ
APDS-9960 gesture sensor -3

ምስሎች

APDS-9960 gesture sensor module -2
APDS-9960 gesture sensor module -2
APDS-9960 gesture sensor module -1
APDS-9960 gesture sensor module -1
APDS-9960 gesture sensor -3
APDS-9960 gesture sensor -3
Arduino wiring for APDS9960 Gesture sensor
Arduino wiring for APDS9960 Gesture sensor
1-Code for an APDS-9960 gesture sensor for Arduino
ቋንቋ: C++
/*
 * Code for APDS-9960 Gesture sensor for Arduino
 * This code is to detect gestures of your hand, either moving it up, down, left, or right; other gestures.
 * can be detected and used to control something else.

 * Watch the APDS-9960 Gesture sensor video https://youtu.be/qzSgZV_fbxI
 * Get this code from https://robojax.com


 * Code used in video by Ahmad Shamshiri for Robojax.com
 * on December 31, 2016, at 6:53 AM in Ajax, Ontario, Canada
  * Permission granted to share this code, given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purposes only.

GestureTest.ino
APDS-9960 RGB and Gesture Sensor
Shawn Hymel @ SparkFun Electronics
May 30, 2014
https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor

Tests the gesture sensing abilities of the APDS-9960. Configures
APDS-9960 over I2C and waits for gesture events. Calculates the
direction of the swipe (up, down, left, right) and displays it
on a serial console. 

To perform a NEAR gesture, hold your hand
far above the sensor and move it close to the sensor (within 2
inches). Hold your hand there for at least 1 second and then move it
away.

To perform a FAR gesture, hold your hand within 2 inches of the
sensor for at least 1 second and then move it away (out of
range) of the sensor.

Hardware Connections:

IMPORTANT: The APDS-9960 can only accept 3.3V!
 
 Arduino Pin  APDS-9960 Board  Function
 
 3.3V         VCC              Power
 GND          GND              Ground
 A4           SDA              I2C Data
 A5           SCL              I2C Clock
 2            INT              Interrupt

Resources:
Include Wire.h and SparkFun_APDS-9960.h

Development environment specifics:
Written in Arduino 1.0.5
Tested with SparkFun Arduino Pro Mini 3.3V

This code is beerware; if you see me (or any other SparkFun 
employee) at the local, and you've found our code helpful, please
buy us a round!

Distributed as-is; no warranty is given.
***************************************************************
*/

#include <Wire.h>
#include <SparkFun_APDS9960.h>
Servo myservo;  // create servo object to control a servo

// Pins
#define APDS9960_INT    2 // Needs to be an interrupt pin

// Constants

// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;

void setup() {

  // Set interrupt pin as input
  pinMode(APDS9960_INT, INPUT);

  // Initialize Serial port
  Serial.begin(9600);
  Serial.println();
  Serial.println(F("--------------------------------"));
  Serial.println(F("SparkFun APDS-9960 - GestureTest"));
  Serial.println(F("--------------------------------"));
  
  // Initialize interrupt service routine
  attachInterrupt(0, interruptRoutine, FALLING);

  // Initialize APDS-9960 (configure I2C and initial values)
  if ( apds.init() ) {
    Serial.println(F("APDS-9960 initialization complete"));
  } else {
    Serial.println(F("Something went wrong during APDS-9960 init!"));
  }
  
  // Start running the APDS-9960 gesture sensor engine
  if ( apds.enableGestureSensor(true) ) {
    Serial.println(F("Gesture sensor is now running"));
  } else {
    Serial.println(F("Something went wrong during gesture sensor init!"));
  }
}

void loop() {
  if( isr_flag == 1 ) {
    detachInterrupt(0);
    handleGesture();
    isr_flag = 0;
    attachInterrupt(0, interruptRoutine, FALLING);
  }
}

void interruptRoutine() {
  isr_flag = 1;
}

void handleGesture() {
    if ( apds.isGestureAvailable() ) {
    switch ( apds.readGesture() ) {
      case DIR_UP:
        Serial.println("UP");
        break;
      case DIR_DOWN:
        Serial.println("DOWN");
        break;
      case DIR_LEFT:
        Serial.println("LEFT");
        break;
      case DIR_RIGHT:
        Serial.println("RIGHT");
        break;
      case DIR_NEAR:
        Serial.println("NEAR");
        break;
      case DIR_FAR:
        Serial.println("FAR");
        break;
      default:
        Serial.println("NONE");
    }
  }
}
2-Source code for controlling a servo with your hand
ቋንቋ: C++
/****************************************************************
Modified for RoboJax by A.B.S. on May 09, 2017
in Ajax, Ontario, Canada. www.RoboJax.com


Original Source:
APDS-9960 RGB and Gesture Sensor
Shawn Hymel @ SparkFun Electronics
May 30, 2014
https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor


Distributed as-is; no warranty is given.
****************************************************************/

#include <Wire.h>

// added by RoboJax
#include <Servo.h>

#include <SparkFun_APDS9960.h>


Servo myservo;  // create servo object to control a servo // added by RoboJax

// Pins
#define APDS9960_INT    2 // Needs to be an interrupt pin

// Constants

// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;

void setup() {
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  // Set interrupt pin as input
  pinMode(APDS9960_INT, INPUT);

  // Initialize Serial port
  Serial.begin(9600);
  Serial.println();
  Serial.println(F("--------------------------------"));
  Serial.println(F("SparkFun APDS-9960 - GestureTest"));
  Serial.println(F("--------------------------------"));
  
  // Initialize interrupt service routine
  attachInterrupt(0, interruptRoutine, FALLING);

  // Initialize APDS-9960 (configure I2C and initial values)
  if ( apds.init() ) {
    Serial.println(F("APDS-9960 initialization complete"));
  } else {
    Serial.println(F("Something went wrong during APDS-9960 init!"));
  }
  
  // Start running the APDS-9960 gesture sensor engine
  if ( apds.enableGestureSensor(true) ) {
    Serial.println(F("Gesture sensor is now running"));
  } else {
    Serial.println(F("Something went wrong during gesture sensor init!"));
  }
}

void loop() {
  if( isr_flag == 1 ) {
    detachInterrupt(0);
    handleGesture();
    isr_flag = 0;
    attachInterrupt(0, interruptRoutine, FALLING);
  }
}

void interruptRoutine() {
  isr_flag = 1;
}

void handleGesture() {
    if ( apds.isGestureAvailable() ) {
    switch ( apds.readGesture() ) {
      case DIR_UP:
        Serial.println("UP");
        break;
      case DIR_DOWN:
        Serial.println("DOWN");
        break;
      case DIR_LEFT:
        Serial.println("LEFT");
        myservo.write(180);  // added by RoboJax
        break;
      case DIR_RIGHT:
        Serial.println("RIGHT");
        myservo.write(0);   // added by RoboJax
        break;
      case DIR_NEAR:
        Serial.println("NEAR");
        break;
      case DIR_FAR:
        Serial.println("FAR");
        break;
      default:
        Serial.println("NONE");
    }
  }
}

እንደሚያስፈልግዎት ይችላል

ምንጮች እና ምንጮች

አሁን ምንም ምንጮች የለም።

ፋይሎች📁

ሌላ ፋይሎች

  • APDS9960 ዳታስሄት
    ይህ የAPDS9960 ቺፕ ዳታሺት ነው። ለበለጠ መረጃ ይህን ፋይል ይመልከቱ።
    robojax-gesture-APDS9960_datasheet.pdf 0.89 MB
  • APDS9960 Gesture Library
    Arduino library for the APDS9960 gesture, proximity, and color sensor. Provides functions to initialize the sensor, read gesture data, and configure detection thresholds. Supports I2C interface and operates at 3.3V.
    robojax-APDS9960-gesture-library.zip 0.30 MB
  • APDS9960 Gesture Datasheet
    Datasheet for the APDS9960 digital proximity, ambient light, RGB and gesture sensor. Features I2C interface, gesture detection with directional output, and operates at 2.4-3.6V.
    robojax-APDS9960-gesture-datasheet.pdf 0.89 MB
  • APDS-9960 Gesture sensor Library
    from Robojax.com
    robojax-gesture-APDS9960-Library.zip 0.30 MB