Help With Using the mpu6050 as a mouse with Leonardo

I recently bought an mpu6050 to use as a mouse, as I am doing a project which involves creating a glove with the functionality of full computer mouse control. I want this glove to be able to control a mouse based to where it is moved. So, if the glove moves to the right, so does the mouse.

The MPU6050_Code_3.ino file is the code I am using to accomplish this. I found it on GitHub. My mpu6050 wasn't showing up, so I tried this I2c scanner off the arduino website:

http://playground.arduino.cc/Main/I2cScanner

It looks like the source of my problems is the INT connection to the Arduino. This is how I currently have my mpu6050 configured with my Arduino Leonardo:

VCC -> 3.3V

GND -> GND

SCL -> SCL

SDA -> SDA

INT -> Digital Pin 3

Peter_n from here: Leonardo + MPU-6050 + Interrupt = hangs - Sensors - Arduino Forum

said that I have to change my interrupt pin in the library. How do I do this? Which library?

This code here governs the interrupt pin:

// enable Arduino interrupt detection
Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)..."));
attachInterrupt(0, dmpDataReady, RISING);
mpuIntStatus = mpu.getIntStatus();

I tried changing the Zero to something else in accordance to the Arduino reference for attachInterrupt() (https://www.arduino.cc/en/Reference/AttachInterrupt) but it didn't work.

I need to get my code working.

Any help is much appreciated.

Thank you in advance.

MPU6050_Code_3.ino (22.5 KB)

Hi, welcome to the forum.

You are trying to make existing code to run. Did that code work in the end ?

If you have a MPU-6050 module without voltage regulator, use 3.3V to power it, because 5V will damage it.
If the MPU-6050 module has a voltage regulator, you better use 5V to power it.

The code has parts from the i2cdevlib.
The attachInterrupt() connects the interrupt to the software.
https://www.arduino.cc/en/Reference/AttachInterrupt
Leonardo Pin 3 is int.0, but pin 3 is also SCL :o
You can see it in the pinmapping page : https://www.arduino.cc/en/Hacking/PinMapping32u4

You could try Pin 7 int.4 again, but I'm not sure if that worked.
For Pin 7, connect INT to Digital Pin 7, and use attachInterrupt(4, dmpDataReady, RISING) ;

Perhaps it is easier to use Pin 0.
For Pin 0, connect INT to Digital Pin 0, and use attachInterrupt(2, dmpDataReady, RISING) ;

Did the i2c_scanner work well ?

Did you try the test sketch to get some raw data from the MPU-6050 ?
http://playground.arduino.cc/Main/MPU-6050
Move the sensor and check if the numbers change.

If you install the i2cdevlib (the original and newest one), then you could try the i2cdevlib example without 'dmp', which does not use the interrupt. If that is okay, you only have to add the interrupt.
i2cdevlib : http://www.i2cdevlib.com/
The example without interrupt : https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/Examples/MPU6050_raw/MPU6050_raw.ino

Do you use the newest Arduino IDE ? and the newest i2cdevlib libraries ?