Head Mouse With MPU6050 and Arduino Micro

37,667

252

44

Introduction: Head Mouse With MPU6050 and Arduino Micro

About: Hi, I'm Gabry295, and I like doing electronic things, even if at the moment I have only one Instructable :) I like robots and everything related, aaand videogames. Contact me for any question, I'll answer glad…

Hi everyone, here it is my new project, a mouse controlled with the movement of the head!
I decided to make this project once I received my accelerometer/gyroscope MPU6050 from IC Station, and I wanted to do something useful with this.
Then I found out that a "Head Mouse" already exists, made by Martin Millmore with another accelerometer/gyroscope: https://www.instructables.com/id/Head-Mouse-Game-controller-or-disability-aid/

Well here it is my version, made with an Arduino Micro and a MPU6050.

Thanks to IC Station http://www.icstation.com/ for the accelerometer/gyroscope they sent me, allowing me to create this project!

Step 1: Materials and Tools Needed

Materials needed:
- Arduino Micro;
- accelerometer/gyroscope MPU6050;
- a Compeed box (I found this comfortable as Martin Millmore said in his guide);
- an elastic band;
- micro USB cable to USB type B (like those used for Android smartphones);
- cables;
- a pcb board;
- glue, or better, Sugru.

Tools needed:
- a computer with the Arduino IDE installed;
- soldering station;
- mini drill.

Step 2: Building

1) Solder on the pcb board the pins like in the image: pin 2 of Arduino to pin SDA, pin 3 to SCL, pin 5V to PWR, pin GND to GND.
2) Make a hole with the dremel on the Compeed box so the micro USB cable can reach the Arduino Micro, and two straight holes for the elastic band.
3) glue the board to the box and add the elastic band.

Step 3: Code

Connect the board to your computer and load first the "Test" code to the Arduino to test if everything work fine. You'll probably need to change some values (everything is written in the code's comments) since I had to add a constant, beacuse values from the gyroscope are not "zero" when I'm not moving.
Use the Serial Monitor to check if you need to fix the "zero" of the gyroscope.
Once you found the right values you can load the program deleting the "Serial.print" part, that is equivalent to the standard code.
If you want the click function after a delay of time since the pointer has been in a 10x10 pixel zone load the code "with_click" to Arduino Micro.

Here there are the codes:

- standard code with only movement: https://www.dropbox.com/s/hnrhdtsoqzi8azr/Mouse_Gyro_ENG.ino?dl=0

- code to test the output: https://www.dropbox.com/s/t2f63ichd4g93n1/Mouse_Gyro_TEST_ENG.ino?dl=0

- code with movement and click after 2 seconds: https://www.dropbox.com/s/vdsg8jo1toebt4d/Mouse_Gyro_with_click_ENG.ino?dl=0

To use them you'll need the MPU6050 and I2C libraries:

MPU 6050: http://arduinomeetslinux.com/download/MPU6050.zip

I2C: http://arduinomeetslinux.com/download/I2Cdev.zip

In this site I found the libraries and the code from which I developed the programs of my project: http://arduinomeetslinux.com/content.php?p=5

Link to Martin Millmore's project with the LSM9DS0 instead of the MPU6050: https://www.instructables.com/id/Head-Mouse-Game-controller-or-disability-aid/

1 Person Made This Project!

Recommendations

  • Big and Small Contest

    Big and Small Contest
  • Make It Bridge

    Make It Bridge
  • Game Design: Student Design Challenge

    Game Design: Student Design Challenge

44 Comments

0
magicbillo80
magicbillo80

Question 2 years ago on Step 1

Ciao sono Roberto avrei bisogno di farti costruire un circuito con Arduino. Se sei interessato scrivimi un messaggio ti lascio il mio Cel 3287511422 ok

0
ErdemD5
ErdemD5

Question 4 years ago

kodu halledemedim acil ödevim var.
kod'da kütüphaneleri indirmeme rağmen hatta veriyor.!!!!!!!!!!!!!

0
banjing
banjing

5 years ago

Hi, tried using this tutorial with my arduino pro micro and mpu6050, got the correct connections but unfortunately its not working, can you help me why please. Thanks.

0
syaifulhuda
syaifulhuda

Reply 4 years ago

what kind of error..?? i use it too.. and it worked.. but it still need the calibration

0
ErdemD5
ErdemD5

Question 4 years ago

kod için yardım edermisiniz acil !!!

0
unzquadatr
unzquadatr

Tip 4 years ago

I need the pdf of the code ...

0
nithildass
nithildass

Question 4 years ago

Mouse_Gyro_ENG:33: error: 'Mouse' not found. Does your sketch include the line '#include <Mouse.h>'?
Mouse.move(vx, vy);

0
Clen
Clen

Answer 4 years ago

You must use an Arduino with Mouse libraries compatibility, like Micro or Leonardo.

0
Clen
Clen

Tip 4 years ago

Hello, first of all, I must say thank you for helping me doing this project. But I'd like to improve your code, with your code you just only click once, so you can't open folders, in order to be able to open folders I suggest you to write 1 click and 1 press with a delay between them, so you don't click twice but it opens the folder too.

I'm adding an image with what I mean to change.

asasasa.png
0
KrzysztofS10
KrzysztofS10

5 years ago

Always easier to start something new when someone walks you through it, thanks :)
I soldered the MPU6050 directly to the Arduino to save space (4cm of cables in all) and the "at rest" values for my module were -700 and 75.
Mounted it into my DIY headlamp (left ear has a LED brightness knob, maybe I'll put mouse sensitivity over the right?

0
Gabry295
Gabry295

Reply 5 years ago

WOW! I'm really happy it was helpful!
Your project is really interesting, the robot looks really good!
I'll take a better look when I have more time, I'm interesting in the algorithm that control the track of the robot

0
ICStation13
ICStation13

5 years ago

Thanks for your awesome project. Great~~

0
Ayudas ParaT
Ayudas ParaT

5 years ago

great work,congratulations

0
YoyOA2
YoyOA2

5 years ago

can this be done with a arduino mega ?

0
Gabry295
Gabry295

Reply 5 years ago

No, you need an Arduino Micro or Leonardo, which have the "ATmega32u4" that interfaces directly with the PC and can be recognized as mouse or keyboard. See more by Googling "Arduino Leonardo" and "Arduino Micro" and check the description on the Arduino official sites.

0
YoyOA2
YoyOA2

Reply 5 years ago

ok.

i could implement other tasks, such as sustained click or secondary click, this with respect to programming?

0
PhilL76
PhilL76

5 years ago

I made a version which runs on every Arduino model using serial communication and python, but apparently I can't post the link here D:

0
ph77894456
ph77894456

6 years ago

Hi Gary, can u tell me what is "200" in your sketch? Thank u very much :)