Magform
Published © GPL3+

ThimbleKrox - Mouse Control with Your Fingers

A thimble which, thanks to a GY-521 and an Arduino Leonardo, is able to control the mouse pointer.

BeginnerFull instructions provided1.5 hours7,897

Things used in this project

Hardware components

Arduino Micro
Arduino Micro
×1
SparkFun Triple Axis Accelerometer and Gyro Breakout - MPU-6050
SparkFun Triple Axis Accelerometer and Gyro Breakout - MPU-6050
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Optional

Story

Read more

Custom parts and enclosures

ThimbleKrox 3D printable model

For those who prefer to take the models from Thingiverse

Steampunk thimble for ThimbleKrox

Support required

Classic thimble for ThimbleKrox

No support required

Schematics

Schematic for the Thimble

Code

ThimbleKrox code

Arduino
Main code for ThimbleKrok
//Code to control the mouse pointer through the movement of a finger
//To calibrate the device run "ThimbleKrox calibration code" and follow the tutorial found at https://www.hackster.io/projects/dd8881/
//The lines that need to be changed for calibration have "//calibration line" 
//code write by Magform

#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>
#include <Mouse.h>

MPU6050 mpu;
int16_t ax, ay, az, gx, gy, gz;
int vx, vy;
int sensibility=10;                  //Change this value to change the sensitivity of the device
        

void setup() {
  Serial.begin(9600);
  Wire.begin();
  mpu.initialize();
  if (!mpu.testConnection()) {       //check connection with the MPU-6050, if there is no connection stop to work
    while (1);
    }
}

void up(){
  Mouse.move(0, -sensibility);
  }
void down(){
  Mouse.move(0, sensibility);
  }
void left(){
  Mouse.move(-sensibility, 0);
  }
void right(){
  Mouse.move(sensibility, 0);
  }


void loop() {
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
  
  if(ax>=15000){                          //calibration line
    right();
  }
  if(ax<=-9000){                         //calibration line
    left();
  }
    
  if(ay<=-8000){                          //calibration line
    up();
  }
  if(ay>=10000){                          //calibration line
    down();
  }

//uncomment the following lines to set the right click with a sprint up and the left click with a sprint down (Work in progress part)
/*
  if(gy>=20000){                         //calibration line        
    Mouse.click(MOUSE_RIGHT);
    delay(100);
  }
  if(gy<=-20000){                        //calibration line
    Mouse.click(MOUSE_LEFT);
    delay(100);
  }
*/

delay(10);
}

ThimbleKrox calibration code

Arduino
Code for calibration of ThimbleKrox
//Code to calibrate the ThimbleKrox
//To calibrate the device run this code and follow the tutorial found at https://www.hackster.io/projects/dd8881/
//The lines that need to be changed (as the other code) for calibration have "//calibration line" 
//code write by Magform

#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>
#include <Mouse.h>

MPU6050 mpu;
int16_t ax, ay, az, gx, gy, gz;
int vx, vy;
int Nwrong=1;

void setup() {
  Nwrong=1;
  Serial.begin(9600);
  Wire.begin();
  mpu.initialize();
  while(Nwrong!=0){
  if (!mpu.testConnection()) { 
   Serial.print("Wrong connection number: "); 
   Serial.print(Nwrong);
   Nwrong++;
   delay(1000);
      }else{
        Nwrong=0;
        }
      
      }
}

void up(){
  Serial.print(" up ");
  }
void down(){
  Serial.print(" down ");
  }
void left(){
  Serial.print(" left ");
  }
void right(){
  Serial.print(" right ");
  }
void rightclick(){
    Serial.print(" RightClick ");;
  }
void leftclick(){
    Serial.print(" LeftClick ");;
  }
  
void loop() {
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

   if(ax>=15000){                          //calibration line
    right();
  }
  if(ax<=-9000){                         //calibration line
    left();
  }
    
  if(ay<=-8000){                          //calibration line
    up();
  }
  if(ay>=10000){                          //calibration line
    down();
  }

//uncomment the following lines to set the right click with a sprint up and the left click with a sprint down (Work in progress part)
/*
  if(gy>=20000){                         //calibration line        
    rightclick();
    delay(100);
  }
  if(gy<=-20000){                        //calibration line
    leftclick();
    delay(100);
  }
*/


  Serial.print(" | gx= ");
  Serial.print(gx);
  Serial.print(" gy= ");
  Serial.print(gy);
  Serial.print(" gz= ");
  Serial.print(gz);

  
  Serial.print(" | ax= ");
  Serial.print(ax);
  Serial.print(" ay= ");
  Serial.print(ay);
  Serial.print(" az= ");
  Serial.print(az);
  Serial.print("\n");
  
  delay(5000);                     
}

ThimbleKrox

Credits

Magform

Magform

2 projects • 4 followers

Comments