Mouse Track - virtualization becomes more real



Article No. 2
Article No. 3

Hello. Today I want to share with you my, I’m not afraid of the word, achievement. I made an unusual mouse. This is a glove-shaped manipulator with 5 keys and an accelerometer. But first things first. First, a little background.

The Arduino Project

It all started with what I learned about the Arduino project . Arduino is a hardware computing platform whose main components are a simple I / O board and a Processing / Wiring development environment. Arduino can be used both for creating stand-alone interactive objects and can be connected to software running on a computer (for example, Macromedia Flash, Processing, Max / MSP, Pure Data, SuperCollider).- Wikipedia tells us. I will explain a little. In fact, Arduino is a debug board based on Atmel microcontrollers . Of course, buying an Arduino scarf is much more expensive than buying a microcontroller (hereinafter MK) and making the debug board yourself. But, in this project there is one big plus (I think it's worth paying for this) for big beginners in programming, which simplifies the process of writing programs and firmware MK - this is the Arduino IDE development environment , which includes the main libraries for working with peripheral devices MK. The Wiring development language is the same C ++, only with libraries and functions for working with MK (standard language functions are, of course, available).

So, it became interesting to me and I ordered myself a debugging board based on the Atmega 1280 MK. And later, two small scarves based on the Atmega 328 MK. But this is not about that. Having tried my hand at small “projects”, I decided to do something really interesting. But it was interesting to make a mouse - a glove.

Accelerometer and the idea of ​​a glove

Without thinking twice , I ordered the accelerometer MMA7260QR2 . I thought to realize the movement of the mouse precisely with the help of an accelerometer. But after experimenting with him, I realized that the principle of his action would not allow us to do just moving the mouse cursor. Therefore, I decided to apply it for another function - it will replace the mouse roller, as well as some other actions. But then again, first things first.

The idea is this: on the glove is a device with 5 buttons and an accelerometer. The data is transferred by MK to the computer via the comport (my arduino board is connected via mini-usb, that is, the com port is implemented on the usb bus using the FTDI converter chip, so the computer sees the arduino as a com port), the program on the computer processes the received data and acts on them. I decided to move the cursor using a webcam and an LED on the glove, since it would not work with an accelerometer. Freeware FreeTrackallows this to be implemented. In short, this is a freely manageable program that processes video from a web camera and receives data on the location of the LED (or several LEDs) in space. The program is intended for tracking in -avia, -auto simulators, shooters and so on. It has the function “emulate a mouse”, which I used.

Having visited a local radio goods store, I bought 5 microswitches (“mikriki” among the people) from mice and began to develop a board (a platform that I will put on the glove later), on which should be located:
1) a microcontroller board;
2) 5 "mikrik";
3) infrared LED;
4) accelerometer.

The accelerometer needed to be "planted" on its own scarf (its dimensions are 6x6 mm), which I did with my dad. On the manual for the accelerometer, I drew a board in the Sprint Layout program and on the technology for manufacturing printed circuit boards at home (using a laser printer and iron), my father and I etched this small scarf at home. Then I connected it to MK and experimented with it.

Arduino nano: description

Microcontroller
ATmega328
Operating voltage (logic level)
5 V
Input voltage (recommended)
7-12 V
Input voltage (limit)
6-20 V
Analog input
8 lines. ADC 10-bit
Digital Inputs / Outputs
14 (6 of which can be used as PWM outputs)
Direct current through the input / output
40 mA
Flash memory
32 Kb (ATmega328) with 2 Kb used for
RAM loader
2 Kb
EEPROM
1 Kb
Clock frequency
16 MHz
Dimensions
1.85 cm x 4.2 cm



Making the motherboard - the platform

After I figured out how to work with the accelerometer, I clearly decided to make the devised device. I chose a sports bicycle glove as a glove. It is affordable and has a good view.

So, having everything you need to build the device, I set about developing a scheme for connecting all this to MK. Honestly, there is nothing complicated. But I had to draw the diagram more than once. Having finished the scheme, I turned to my dad for help in making a printed circuit board all using the same technology for making printed circuit boards at home. After the motherboard was made, I saw one mistake - the place for the accelerometer did not work out where it was planned, due to the fact that when drawing the circuit board I did not take into account the dimensions of the buttons. Well, they learn from their mistakes.

Board soldering - platforms

This stage was the most difficult for me, since I do not solder well. But, after dad showed how to do it right and helped me, soldering became easier for me. I will not describe in detail this stage. I will show only the result - a board with soldered MK and parts on it.
This is how the board looks.

Firmware MK

I will describe only the principle of operation of the firmware (programs in the memory of MK). So, 5 keys, an accelerometer and an LED are connected to the MK. All I need is to get data about the state of the buttons (pressed or not) and data from the accelerometer (which direction it is tilted and how much it is tilted). All this happens in an endless cycle (this is the principle of MK’s action - to execute the program cyclically while it is on). Data is sent on a com - port to a computer.

I can say that having basic knowledge of the C ++ language and programming principles, it is not difficult to write firmware. The Arduino IDE development environment also contributes to this, thanks to which you do not have to read datasheets on the MK for hours and find out which register is responsible for which function of the MK. But this, of course, is also not difficult, and you need to know this at least for yourself, to know what you are dealing with. But arduino allows you to make a “quick start” without delving into the intricacies of programming MK, which I use.

The Mouse Track program for receiving data from a glove

Principle of action: in a separate thread in an infinite loop, the desired com - port is interrogated. The program receives data from the glove (from MK) and performs the appropriate actions. For example, if button1 is pressed, then this is reported on the program's com port and it performs the action “button1 is pressed”. If button1 is released, “button1 is released” is reported. I wrote the program in Delphi 7. I implemented the following - for each finger you can assign one of 5 mouse actions (LMB, SCM, RMB, roller up, roller in) or one of 4 actions with a window (close, minimize, move, maximize / restore ) The situation is the same with the accelerometer - the same functions can be assigned to tilts to the right, left, forward, backward. The dead zone of the accelerometer is also adjustable. I measure the tilt of the accelerometer from 0% to 100%. So, the tilt threshold of the accelerometer command can be adjusted. For example, the command will be executed if the threshold is set to 50%, that is, if the accelerometer tilts by half. And so for each axis. Speaking of axles. In the accelerometer that I used, 3 of them are x, y, z. But I only involved x and y.



In the “mouse emulation” tabs, such functions: LMB, SCM, RMB, scroll the movie up / down. In the “Action with window” tabs, the following functions: move the window, close the window, minimize the window, maximize / restore the window.



You can also use the "Hot Keys" gloves. That is, the combination of some keys to call the assigned program.



Design and appearance

Finger pressing the key, I came up with the following - the finger bends, pulls the wire soldered (in my case, mounted on silicone) to the push of a button and thus the button is pressed. Such an easy way. This is how it all looks.

1 - Arduino nano board based on Atmega328 MK; 2 - button; 3 - infrared LED; 4 - accelerometer MMA7260QR2; 5 - a guide (from a bicycle brake cable); 6 - Velcro



Finally, a video of the work of this device. At the expense of games, I’ll say that it works only in those that use the system cursor.


UPD
Facilitated the appearance and abandoned the glove (it is inconvenient to type on the keyboard, because the fabric is thick and does not feel touch)


Article No. 2
Article No. 3

Also popular now: