My Hand gesture Smart mouse





My Hand gesture Smart mouse

Wave your hands and light turns on. Can you believe this magic turns into reality?

Meet the Gesture Sensor which offers touch-less gesture sensing - you can issue orders simply with a swipe of your hand! Furthermore, it supports RGB color detecting and ambient light measuring. With this new sensor, traditional switch can be replaced.

Operating Voltage: 3.3-5V
I2C interface x1
Interrupt pin x1
Detecting range: 100mm (3.94")
Module size: 18.3x16.4mm (0.72x0.65")

This project shows detecting gestures of hand to RIGHT, LEFT, UP, DOWN and also Ambient color and proximity detection using Arduino module APDS-9960 .

Arduino Nano+ RGB and Gesture Sensor(5pin and 6pin, purple board) which control the light bulb - Arduino Nano+RGB and Gesture Sensor APDS-9960(6pin .

Circuit Diagram :)

PY Serial :)
        

USE this Command on Windows cmd 
      
           pip install pyautogui
           pip3 install pyautogui


Arduino code :)

#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("please Subscribe to my Channel Zeeatech"));
  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");
    }
  }
}
 
Python Code :)

# please Subscrice zeea tech channel
import serial #Serial imported for Serial communication
import time #Required to use delay functions
import pyautogui   #Required to to perform actions


ArduinoSerial = serial.Serial('com7',9600) #Create Serial port object called arduinoSerialData
time.sleep(2) #wait for 2 seconds for the communication to get established


while 1:
    incoming = str (ArduinoSerial.readline()) #read the serial data and print it as line
    print (incoming)
    
    if 'NEAR' in incoming:
        pyautogui.press('win')

    if 'FAR' in incoming:
        pyautogui.press('space')


    if 'LEFT' in incoming:
        pyautogui.hotkey('ctrl', 'left')  


    if 'RIGHT' in incoming:
        pyautogui.hotkey('ctrl', 'right') 


    if 'DOWN' in incoming:
         pyautogui.hotkey('ctrl', 'down')
        


    if 'UP' in incoming:
        pyautogui.hotkey('ctrl', 'up')


    incoming = "";

 

Comments

Popular posts from this blog

How to make a radar using Arduino and Processing IDE

Smart gesture robot

How to control LCD via Bluetooth using Smartphone #2