ویژگیهای ماژول سنسور حالت دست مادون قرمز APDS-9960
ماژول سنسور حالت دست مادون قرمز APDS-9960 یک دستگاه پیشرفته است که تعامل با دستگاه های الکترونیکی را از طریق حرکات دست امکانپذیر میکند. این ماژول از فناوری مادون قرمز برای تشخیص دقیق حرکات دست استفاده میکند و یک گزینه کنترل هندزفری برای اپلیکیشنهای مختلف ارائه میدهد. APDS-9960 با توانایی تشخیص حرکات دست مانند کشیدن، ضربه زدن و اسکرول، برای رابطهای کنترل بدون لمس، کنسولهای بازی و لوازم هوشمند بسیار کاربرد دارد. طراحی جمع و جور و یکپارچهای دارد، بنابراین هم برای علاقهمندان و هم برای حرفهایها مناسب است.
برای اطلاعات بیشتر میتوانید این دیتاشیت را مطالعه کنید
پیناوت ماژول سنسور حالت دست APDS-9960
ماژول سنسور حالت دست مادون قرمز APDS-9960 شش پین دارد:
- VCC/VL: ورودی منبع تغذیه برای ماژول APDS-9960 (3.3 ولت)
- GND: زمین
- SCL: خط کلاک سریال برای ارتباط با میکروکنترلرها
- SDA: خط داده سریال برای پیکربندی تنظیمات ماژول
- INT: پین درخواست وقفه به میکروکنترلر
میتوانید پیناوت این ماژول را در تصویر زیر مشاهده کنید.
لوازمی که به آن احتیاج دارید
قطعات مورد نیاز
راهاندازی ماژول سنسور حالت دست مادون قرمز APDS-9960 با آردوینو
گام اول: مدار
مدار را مطابق با شکل زیر ببندید. (استفاده از صفحه نمایش اختیاری است.)
گام دوم: نصب کتابخانه
گام سوم: کد
برای راهاندازی برد بدون نمایشگر، کد زیر را در آردوینو آپلود کنید.
/*
Create on February 07, 2024
Create by MohammedDamirchi base of https://electropeak.com/apds-9960-infrared-gesture-sensor-module
<blockquote class="wp-embedded-content" data-secret="KygJPsr5OE"><a href="https://electropeak.com/learn/">Home</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="“Home” — Electropeak" src="about:blank" data-secret="KygJPsr5OE" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" data-rocket-lazyload="fitvidscompatible" data-lazy-src="https://electropeak.com/learn/embed/#?secret=Muy20C9pJG#?secret=KygJPsr5OE"></iframe><noscript><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="“Home” — Electropeak" src="https://electropeak.com/learn/embed/#?secret=Muy20C9pJG#?secret=KygJPsr5OE" data-secret="KygJPsr5OE" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></noscript>
*/
#include <Arduino.h>
#include <Arduino_APDS9960.h>
void setup()
{
Serial.begin(9600);
while (!Serial)
;
if (!APDS.begin())
{
Serial.println("Error initializing APDS-9960 sensor.");
}
Serial.println("Color Sensor ...");
}
void loop()
{
// check if a color reading is available
while (!APDS.colorAvailable())
{
delay(5);
}
int r, g, b;
// read the color
APDS.readColor(r, g, b);
// print the values
Serial.print("r = ");
Serial.println(r);
Serial.print("g = ");
Serial.println(g);
Serial.print("b = ");
Serial.println(b);
Serial.println();
// wait a bit before reading again
delay(1000);
}
/*
Create on February 07, 2024
Create by MohammedDamirchi base of https://electropeak.com/apds-9960-infrared-gesture-sensor-module
<blockquote class="wp-embedded-content" data-secret="KygJPsr5OE"><a href="https://electropeak.com/learn/">Home</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="“Home” — Electropeak" src="about:blank" data-secret="KygJPsr5OE" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" data-rocket-lazyload="fitvidscompatible" data-lazy-src="https://electropeak.com/learn/embed/#?secret=Muy20C9pJG#?secret=KygJPsr5OE"></iframe><noscript><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="“Home” — Electropeak" src="https://electropeak.com/learn/embed/#?secret=Muy20C9pJG#?secret=KygJPsr5OE" data-secret="KygJPsr5OE" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></noscript>
*/
#include <Arduino.h>
#include <Arduino_APDS9960.h>
#include <myLCD.h>
void setup()
{
Serial.begin(9600);
beginLCD("APDS9960");
while (!Serial)
;
if (!APDS.begin())
{
Serial.println("Error initializing APDS-9960 sensor.");
fail();
}
success();
printLCD("APDS9960 Color Sensor", 0, true);
printLCD("Red: ", 1);
printLCD("Green: ", 2);
printLCD("Blue: ", 3);
Serial.println("Color Sensor ...");
}
void loop()
{
// check if a color reading is available
while (!APDS.colorAvailable())
{
delay(5);
}
int r, g, b;
// read the color
APDS.readColor(r, g, b);
// print the values
Serial.print("r = ");
Serial.println(r);
Serial.print("g = ");
Serial.println(g);
Serial.print("b = ");
Serial.println(b);
Serial.println();
printLCD(String(r), 1, false, 8);
printLCD(String(g), 2, false, 8);
printLCD(String(b), 3, false, 8);
// wait a bit before reading again
delay(1000);
}
پس از آپلود کد، میتوانید خروجی ماژول را همانطور که در فیلم زیر نشان داده شده است مشاهده کنید.
برای مُد حالت دست از این کد استفاده کنید.
/*
Create on February 07, 2024
Create by MohammedDamirchi base of https://electropeak.com/apds-9960-infrared-gesture-sensor-module
<blockquote class="wp-embedded-content" data-secret="KygJPsr5OE"><a href="https://electropeak.com/learn/">Home</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="“Home” — Electropeak" src="about:blank" data-secret="KygJPsr5OE" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" data-rocket-lazyload="fitvidscompatible" data-lazy-src="https://electropeak.com/learn/embed/#?secret=Muy20C9pJG#?secret=KygJPsr5OE"></iframe><noscript><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="“Home” — Electropeak" src="https://electropeak.com/learn/embed/#?secret=Muy20C9pJG#?secret=KygJPsr5OE" data-secret="KygJPsr5OE" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></noscript>
*/
#include <Arduino.h>
#include <Arduino_APDS9960.h>
void setup()
{
Serial.begin(9600);
while (!Serial)
;
if (!APDS.begin())
{
Serial.println("Error initializing APDS-9960 sensor!");
}
APDS.activeAll();
// for setGestureSensitivity(..) a value between 1 and 100 is required.
// Higher values make the gesture recognition more sensitive but less accurate
// (a wrong gesture may be detected). Lower values makes the gesture recognition
// more accurate but less sensitive (some gestures may be missed).
// Default is 80
// APDS.setGestureSensitivity(80);
Serial.println("Detecting gestures ...");
}
void loop()
{
if (APDS.gestureAvailable())
{
// a gesture was detected, read and print to Serial Monitor
int gesture = APDS.readGesture();
switch (gesture)
{
case GESTURE_UP:
Serial.println("Detected UP gesture");
break;
case GESTURE_DOWN:
Serial.println("Detected DOWN gesture");
break;
case GESTURE_LEFT:
Serial.println("Detected LEFT gesture");
break;
case GESTURE_RIGHT:
Serial.println("Detected RIGHT gesture");
break;
default:
// ignore
break;
}
}
}
پس از آپلود کد، میتوانید کد حالت دست را در سریال مانیتور ببینید.
در صورت نیاز به راهنمایی برای اجرای نمایشگر میتوانید به این لینک مراجعه کنید.
برای راهاندازی برد با نمایشگر، کد زیر را در آردوینو آپلود کنید.
همچنین فایل myLCD را دانلود کرده و در پوشه پروژه خود قرار دهید.
/*
Create on February 07, 2024
Create by MohammedDamirchi base of https://electropeak.com/apds-9960-infrared-gesture-sensor-module
<blockquote class="wp-embedded-content" data-secret="KygJPsr5OE"><a href="https://electropeak.com/learn/">Home</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="“Home” — Electropeak" src="about:blank" data-secret="KygJPsr5OE" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" data-rocket-lazyload="fitvidscompatible" data-lazy-src="https://electropeak.com/learn/embed/#?secret=Muy20C9pJG#?secret=KygJPsr5OE"></iframe><noscript><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" title="“Home” — Electropeak" src="https://electropeak.com/learn/embed/#?secret=Muy20C9pJG#?secret=KygJPsr5OE" data-secret="KygJPsr5OE" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></noscript>
*/
#include <Arduino.h>
#include <Arduino_APDS9960.h>
#include <myLCD.h>
void setup()
{
Serial.begin(115200);
beginLCD("APDS9960");
while (!Serial)
;
if (!APDS.begin())
{
Serial.println("Error initializing APDS-9960 sensor!");
fail();
}
APDS.activeAll();
// for setGestureSensitivity(..) a value between 1 and 100 is required.
// Higher values make the gesture recognition more sensitive but less accurate
// (a wrong gesture may be detected). Lower values makes the gesture recognition
// more accurate but less sensitive (some gestures may be missed).
// Default is 80
// APDS.setGestureSensitivity(80);
success();
printLCD("APDS9960 Gestures", 0, true);
Serial.println("Detecting gestures ...");
}
void loop()
{
if (APDS.gestureAvailable())
{
// a gesture was detected, read and print to Serial Monitor
int gesture = APDS.readGesture();
switch (gesture)
{
case GESTURE_UP:
Serial.println("Detected UP gesture");
printLCD("Detected UP", 2, true);
break;
case GESTURE_DOWN:
Serial.println("Detected DOWN gesture");
printLCD("Detected DOWN", 2, true);
break;
case GESTURE_LEFT:
Serial.println("Detected LEFT gesture");
printLCD("Detected LEFT", 2, true);
break;
case GESTURE_RIGHT:
Serial.println("Detected RIGHT gesture");
printLCD("Detected RIGHT", 2, true);
break;
default:
// ignore
break;
}
}
}
پس از آپلود کد، میتوانید خروجی ماژول را همانطور که در فیلم زیر نشان داده شده است مشاهده کنید.