Introduction: Head Mouse With MPU6050 and Arduino Micro

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/

Comments

author
ICStation13 made it!(author)2017-07-20

Thanks for your awesome project. Great~~

author
Ayudas+ParaT made it!(author)2017-07-07

great work,congratulations

author
YoyOA2 made it!(author)2017-04-28

can this be done with a arduino mega ?

author
Gabry295 made it!(author)2017-04-29

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.

author
YoyOA2 made it!(author)2017-05-29

ok.

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

author
PhilL76 made it!(author)2017-05-28

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:

author
MagicKreator made it!(author)2017-04-20

I made this, with an arduino due, the only problem that i have is that sometimes some axis change their value "random" and this cause that sometimes the pointer move down, Sorry for my english, Thanks for the project

IMG_20170420_144301315.jpg
author
PhilL76 made it!(author)2017-05-28

Maybe you could let the program automatically determine the offset every time it starts. Take a look at the calibrate() function of my version if you don't know how to do this:

https://www.dropbox.com/sh/n2p7cm84r4atbri/AABt7OKbfJY3CsX7ghz_o6gFa?dl=0

author
Gabry295 made it!(author)2017-04-29

Hi MagicKreator, well done! :D
I'm sorry for your problem, I think it's in your accelerometer/gyroscope module, or in your Arduino Due board. Less probable it's the code.

author
ph77894456 made it!(author)2016-10-25

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

author
PhilL76 made it!(author)2017-05-28

The sensitivity.

As the sensor values can vary quite a lot this helps to keep the pointer calm.

If you increase it, the pointer becomes slower,

if you decrease it, the pointer becomes faster.

author
nourdiri made it!(author)2016-12-18

Hi, I need to know what is the principle of working of the gyroscope, accelerometer and magneometer? please.

author
Gabry295 made it!(author)2016-12-18

That explanation is up to Wikipedia! :) here it is:

https://en.wikipedia.org/wiki/Accelerometer

https://en.wikipedia.org/wiki/Gyroscope

https://en.wikipedia.org/wiki/Magnetometer

It would be too long to explain here :P

author
YoyOA2 made it!(author)2017-04-28

can this be done with a arduino mega ?

author
ParthT12 made it!(author)2017-02-25

how can I include right click along with lest click option

author
throbscottle made it!(author)2016-09-13

Very clever, but I don't think I'd like having to keep moving my head to move the cursor!

Now, an EYE tracking mouse, that would be ultra cool! (I bet you could do it with a webcam)

author
ScottW66 made it!(author)2016-09-13

Yeah, an EYE tracking mouse would be super cool!!! Haven't a clue how to do it!

author
avashi made it!(author)2016-11-26

look at the EYETRACKER a open source project easily available and very cheap to make

author
HafizuddinA3 made it!(author)2016-12-07

using arduino nano can use for this project ? where to get libraries for mouse.h

author
Gabry295 made it!(author)2016-12-10

Arduino Nano won't work for this project since it has a different processor and can't be interfaced to the PC like a mouse.

Library Mouse.h is already installed when you install the Arduino IDE

author
throbscottle made it!(author)2016-11-27

Cool - I didn't realise there were these projects around! And now I find it slightly creepy!

author
avashi made it!(author)2016-11-27

i dont think it will work arduino mini dont have capabilities to act like a usb input device like mouse or keyboard please explain me if i am wrong

author
Gabry295 made it!(author)2016-11-29

Right, it's impossible to do with an Arduino Mini since it has an "ATmega328" and other board such Micro and Leonardo has the "ATmega32u4"

author
avashi made it!(author)2016-12-01

yes it work perfectly but their is one issue right now when i connect my Arduino micro and upload the code it work fine but when i disconnect it and it didn't work perfectly it lag too much in movements of cursor and i have to again upload the code to work any solution i am new to atmega32U4 I only work on atmega 328 p , atmega 32 and some pic

author
ClintH16 made it!(author)2016-09-14

I'd be worried about static electricity being generated by that headband touching the components directly.

author
Gabry295 made it!(author)2016-11-17

Me not! There are no dangerous voltages:)

author
PetrB14 made it!(author)2016-09-13

How do you turn around in games like the one on the video or CS or so?? :)

author
MatthewG147 made it!(author)2016-09-13

well, maybe, it could be like a VR, but on a smaller screen like a phone or tablet. So you could play like in your chair or something. It's not totally impossible. what do you think?

author
PetrB14 made it!(author)2016-09-14

I asked how to turn around with this in the game. I mean how to turn more 180 degrees like 360 or more... You probably won't be turning on your chair during the game thus loosing eye contact with screen... So? Any suggestions?

author
MatthewG147 made it!(author)2016-09-14

I mean, you have the screen attached to your head so when you move your head the video moves but the device stays in front of you.

author
Gabry295 made it!(author)2016-09-14

You can set the senisbility so when you rotate your head you cover a bigger angle in the game and you can see behind you without turning your neck too much :)
Anyway I'm still thinking about other solutions, in the end the VR is the best... The screen moves with you!

author
craighissett made it!(author)2016-09-14

You could use a VNC Server on the gaming PC, and a VNC Client on your phone/tablet to show your PC's screen?

author
millmore made it!(author)2016-09-13

Thanks for the shout out! Looks like a good version that you did.

author
Jopapa made it!(author)2016-09-12

Simple y magnifico montaje, gracias por compartir.

www.jopapa.me

author
Gabry295 made it!(author)2016-09-12

Thank you too! :)

About This Instructable

17,904views

238favorites

License:

Bio: 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 ... More »
More by Gabry295:Head Mouse with MPU6050 and Arduino MicroHow to Make a Remote Controlled Robotic Hand With Arduino
Add instructable to: