Things used in this project

Schematics

Touchless mouse schematic
Touchfree mouse schematic i3c2fomggq

Code

Touchless mouseArduino
Works on Arduino that has USB device capabilitie. Tested on Arduino Leonardo.
#include "Bitcraze_PMW3901.h" 
#include <Wire.h> 
#include <VL53L0X.h> 
#include <Mouse.h> 

VL53L0X rangeSensor; 

// Using digital pin 10 for chip select 
Bitcraze_PMW3901 flow(10); 

void setup() { 
 Serial.begin(9600); 
 // Initialize flow sensor 
 if (!flow.begin()) { 
   Serial.println("Initialization of the flow sensor failed"); 
   while(1) { } 
 } 
 // Initialize range sensor 
 Wire.begin(); 
 rangeSensor.init(); 
 rangeSensor.setTimeout(500); 
 // Initialize Mouse 
 Mouse.begin(); 
} 

int16_t deltaX,deltaY; 

void loop() { 
 // Get motion count since last call 
 flow.readMotionCount(&deltaX, &deltaY); 
 // Get single range measurement 
 float range = rangeSensor.readRangeSingleMillimeters(); 

 // Send motion as mouse movement when the hand is between 80 and 200mm
 if (range < 200 && range > 80) { 
   Mouse.move(deltaX, -deltaY, 0); 
 }

 // Press the left mouse button when the hand is bellow 50mm
 if (range < 50) { 
   Mouse.press(); 
 } else { 
   Mouse.release(); 
 } 
} 

Credits

A3947978cc4c8a556432deddcae3be78
Arnaud Taffanel
2 projects • 8 followers
Contact
1464817
Kristoffer Richardsson
3 projects • 4 followers
Developer at Bitcraze
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog