We have seen different types of Human Interface Devices (HIDs), for example mouse and keyboard. In older versions of computer mouse, optical sensors were used to detect movement relative to a surface, thus they require smooth surface to function properly. These mice can work with only two coordinates. With advancements in technology, we are now talking about 3D user interfaces ((3DUIs). So, we must start developing a 3D HID device which have the capability to work with all coordinates.
In this project we are going to make 3D wireless HID device that will give you a whole new experience of using computers and playing online games. With this device, you will be able to control computers and smartphones by just moving your hand in air.
This device can be very helpful in making 3D UI based systems. We can use this device in 3D designing as well. For instance, you can draw any design by moving your hand in the air. Further we can develop such device for 3D holographic display and in VR that gives us a 3D UI.
Best application of this device is that it will enable differently abled people to use computers and smartphones. People who don’t have hands to operate computer or phones can now do so with the help of this device. They can wear this device on their head and operate gadgets by moving their head.
Now, let’s start our Interesting project. First, we need to gather the following components –
- Arduino Pro Mini 5V 16-Mhz
- 2 Bluetooth HC 05
- Mpu 6050 Sensor
- Arduino Leonardo Micro (At mega 32u)
- Jumper wires
- Micro USB Cable
- 4 Push Switch
Bill of material
You also need a either FTDI Module or Arduino Uno to upload code on pro mini.
First of all, we need to install an MPU 6050 library. Open library manager of Arduino IDE and search for MPU6050, then install the library – refer (Fig. 1). After this, we will set one Bluetooth as slave and another as master – follow the Bluetooth instruction on the internet to do this.
As we have installed the library, now we can start the coding part. In the first part of coding, we will include the library for MPU6050 and set the variables for storing values of mpu6050 sensor. After that we can set up sensor and Bluetooth in set up function – for this refer (Fig. 2). I have used Baudrate 9600 in this code.
In the second part of coding, we will send the buttons and sensors data to another Arduino over bluetooth as in pic, refer (Fig 3).
Our Arduino mini code is ready now. So, let’s start coding for Arduino pro micro.
First, we will create variables to store values, then set up Bluetooth to read serial data of sensor – refer (Fig. 4).
In the third part of our coding process, we will create a loop function and get the serial data from Bluetooth. Here in this code, I have used software serial for Bluetooth connection with baudrate of 9600.
After this, check the range value of serial data and assign its value for mouse movement as in Fig. 5.
Next, we will create if () condition to check how the mouse button functions – you can refer (Fig. 6) for this. We can also add extra Keyboard shortcuts and other functions to it as per your desire. Here in this code, I have added button shortcut for copy and paste function. You can create your own custom function according to your use cases.
As we have completed the coding part, we need to connect the components.
|Arduino Mini Pin||
|Arduino Mini SCL||MPU 6050 SCl|
|Arduino Mini SDA||MPU 6050 SDA|
|Arduino Mini VCC||MPU 6050 VCC|
|Arduino Mini GND||MPU 6050 GND|
|Arduino Mini TX||
Bluetooth HC 05 RX
|Arduino Mini RX||
Bluetooth HC 05 TX
|Arduino Mini VCC||
Bluetooth HC 05 +Ve
|Arduino Mini VCC||
Push Switch Pins
|Arduino Mini (A3,A0,A2,A1 )||
Push switch(1, 2,3,4)
Refer Fig. 7 for connection and schematic.
Now, we will connect Arduino Pro Micro with Bluetooth – refer (Fig . 8)
Bluetooth HC 05
Now to upload the code to Pro Mico select the board and port and and press ctrl+ U(Refer fig 9).Now upload the code to Pro mini using the board option (Refer Fig 10). Follow the instructions online to upload the code on Pro Mini. Search How to upload code on pro mini.
Congrats! The wireless HID mouse is ready for use. You can do some awesome tricks with it – you can attach it on your hand or any toy gun and enjoy the real shooting game experience. Attach the device on the tip of a plastic knife and you can play vegetable cutting game with it.
Note:- In the code, I have mentioned A7 pin in Arduino for a keyboard button function but not used it in connection and schematics because some Arduino mini version don’t have this pin. If you have extra A7, A8 pins you can add more switch to it and set keyboard shortcut function according to your choice.